mardi 8 septembre 2020

Pytest how to enforce test collection in subfolder containing pytest.ini

Let's say I have the following folder structure:

MyPackage
- subfolder
-- pytest.ini
-- my_module.py
-- test_module.py

The pytest.ini in subfolder contains this:

[pytest]
python_files = test_*.py my_module*.py

The my_module.py contains test functions like def test_this(). If I call pytest to collect tests in the subfolder, It collects the tests in my_module.py as well, as expected:

pytest --collect-only MyPackage/subfolder

However, if I call pytest for MyPackage, it does not collect the tests in my_module.py, only in test_module.py

pytest --collect-only MyPackage

My question is: Can it be done so that pytest recursively processes the pytest.ini in the subfolder?

In other words: What is the scope of the pytest.ini files in the subfolders? Is ot only processed if pytest is called locally? Is there a way to force pytest to recursively process pytest.ini in subfolders?

Aucun commentaire:

Enregistrer un commentaire