pythonunit-testingpytest

How to tell py.test to skip certain directories?


I tried to use the norecursedirs option inside setup.cfg to tell py.test not to collect tests from certain directories but it seems it does ignore it.

[tool:pytest]
norecursedirs=lib/third

When I run py.test I do see how it does get tests from inside lib/third!


Solution

  • I solved the mystery: If a pytest section is found in one of the possible config files (pytest.ini, tox.ini and setup.cfg), pytest will not look for any others so be sure you define the py.test options in a single file.

    I would suggest using setup.cfg.