How do I tell pbr to use pytest when setup.py test command is invoked?

388 Views Asked by At

While using pbr to simplify Python packaging what do we need to configure in order to make it use pytest when python setup.py test command is executed.

Running pytest works without any problems.

1

There are 1 best solutions below

0
Katrina Brock On

In setup.py:

setup(
    setup_requires=['pbr>=1.9', 'setuptools>=17.1', 'pytest-runner'],
    pbr=True,
)

In setup.cfg (after standard pbr config):

[aliases]
test=pytest

In test-requirements.txt (same directory as requirements.txt):

pytest

If your tests are outside the application code, you will also need to specify your test directory using addopts in setup.cfg. For example, if your directory structure looks like the first example on this page, you should have

[tool:pytest]
addopts = tests