15

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'

proj_name/setup.py

from distutils.core import setup

if __name__ == '__main__':
    setup(name='foo', version='0.1', package_dir={'foo': 'utils'},
          test_suite='tests')

proj_name/tests/foo_test.py

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()

1 Answer 1

17

test_suite is a feature of setuptools. Replace distutils with it:

from setuptools import setup
Sign up to request clarification or add additional context in comments.

2 Comments

Your test_suite should probably contain proj_name.tests, as the documentation suggests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.