You can split up your requirements into “install” dependencies and “test” dependencies like this:
import os
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
install_requires = [
'pyramid',
'pyramid_debugtoolbar',
'waitress',
'requests',
'gunicorn',
'mongoengine',
]
tests_require = [
'mock',
'nose',
]
setup(name="repoapi",
...
install_requires=install_requires,
tests_require=tests_require,
test_suite="nose.collector",
...
)
This way, when someone installs the package, only the “install” dependencies are installed. So, if someone only wants to use the package (and they aren’t interested in running the tests), then they don’t have to install the test dependencies.
When you do want to run the tests, you can use this:
$ python setup.py test
Per the docs:
Note that these required projects will not be installed on the system where the tests are run, but only downloaded to the project’s setup directory if they’re not already installed locally.
Once the “test” dependencies are in place, then it will run the “test_suite” command. Since you mentioned nose as your preferred test runner, I showed how you use “nose.collector” to configure that.
Incidentally, the Django setup.py is not the cleanest example for understanding the basics of setuptools. I think the Sentry setup.py is a better example to learn from.