Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 797
sorin Avatar asked Nov 29 '25 05:11

sorin


1 Answers

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
like image 164
Katrina Brock Avatar answered Nov 30 '25 20:11

Katrina Brock