3

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.

Moses Koledoye
  • 77,341
  • 8
  • 133
  • 139
sorin
  • 161,544
  • 178
  • 535
  • 806

1 Answers1

3

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
Katrina Brock
  • 131
  • 1
  • 3