I\'m trying to figure out how to get python setup.py test
to run the equivalent of python -m unittest discover
. I don\'t want to use a run_tests.p
Python's standard library unittest
module supports discovery (in Python 2.7 and later, and Python 3.2 and later). If you can assume those minimum versions, then you can just add the discover
command line argument to the unittest
command.
Only a small tweak is needed to setup.py
:
import setuptools.command.test
from setuptools import (find_packages, setup)
class TestCommand(setuptools.command.test.test):
""" Setuptools test command explicitly using test discovery. """
def _test_args(self):
yield 'discover'
for arg in super(TestCommand, self)._test_args():
yield arg
setup(
...
cmdclass={
'test': TestCommand,
},
)