How do I get python setup.py test
to work? - Current output:
$ python setup.py test # also tried: `python setup.py tests`
/usr/lib/python2.7/distutils/dist.py:267: \
UserWarning: Unknown distribution option: 'test_suite'
warnings.warn(msg)
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'test'
from distutils.core import setup
if __name__ == '__main__':
setup(name='foo', version='0.1', package_dir={'foo': 'utils'},
test_suite='tests')
from unittest import TestCase, main as unittest_main
class TestTests(TestCase):
def setUp(self):
pass
def test_foo(self):
self.assertTrue(True)
self.assertFalse(False)
if __name__ == '__main__':
unittest_main()
To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.
You can just specify test_suite="tests", and it will pick up everything recursively. Note that each nested directory will need to have an __init__.py file in it. You need to do from setuptools import setup instead of from distutils. core import setup for this option to exist.
As a first step, pip needs to get metadata about a package (name, version, dependencies, and more). It collects this by calling setup.py egg_info . The egg_info command generates the metadata for the package, which pip can then consume and proceed to gather all the dependencies of the package.
test_suite
is a feature of setuptools. Replace distutils with it:
from setuptools import setup
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With