11

I am trying to setup a Python package using setup.py. My directory structure looks like this:

setup.py
baxter/
  __init__.py
  baxter.py
tests/
  test_baxter.py

Here is setup.py:

from setuptools import setup, find_packages
setup(name='baxter',
      version='1.0',
      packages=find_packages()
      )

I first do a python setup.py build. When I then run python setup.py test I immediately get this result:

running test

and nothing else. The unit tests have not run since the tests take at least 15 seconds to finish and the message running test comes back right away.

So it appears that python setup.py test is not finding the unit tests. What am I doing wrong?

1
  • Fun thing - I'm not sure if that's correct, but i have tests_require=['pytest'] in my setup(), and another difference: my tests is under the package directory. And it works without any extra configuration. O, wait, in setup.cfg, I've got [aliases] test = pytest. Try moving tests to baxter/tests, maybe. Commented May 18, 2021 at 20:44

1 Answer 1

12

Pretty simple, add the following to your setup() call:

test_suite="tests",   
Sign up to request clarification or add additional context in comments.

3 Comments

Where tests is the name of the directory containing the test suite. The system automatically finds the test cases.
Errata: not of the directory, but of the package.
This didn't work for me. Is this still applicable for at this time (2018) for Python 3?

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.