I\'m developing my first Python distribution package. My learning curve on Python packaging seems to be leveling off a bit, but I\'m still wrestling with a few open questions. O
After researching this issue, and until someone more experienced has a minute to weigh in to the contrary, my understanding is that the simple answer is: "No, unit tests should not be installed, only included in the source distribution".
In the handful of cases I found where tests were installed, all turned out to be accidental and it's easier than one might think to make the mistake without noticing it.
Here's how it happens:
packages=find_packages()
parameter is used in setup.py so packages can be found without having to list them out explicitly.test
folder is made into a package (by adding __init__.py
) so tests can reference the modules they test using relative naming (like from .. import pkg.mod
).setuptools
installs test
as a separate package, alongside the other(s) in the project. Note this means you can execute import test
in the python interpreter and it works, almost certainly not what you intended, especially since a lot of other folks use that name for their test directory :)The fix is to use the setting: packages=find_packages(exclude=['test'])
to prevent your test directory from being installed.