Repository navigation
Specifying test .py files relative to pytest.ini file. #12993
Replies: 1 comment
|
Use [pytest]
testpaths = tests
python_files = test_*.py
So this: python_files = ^tests/test_*.pydoesn't mean "anchor this pattern to the The responsibilities are separate: testpaths = teststells pytest where to start its default collection when you run: pytestand: python_files = test_*.pytells it which Python filenames inside the collection tree should be considered test modules. You can specify multiple directories too: [pytest]
testpaths =
tests
integration_tests
python_files = test_*.pyOne important limitation: pytest some_other_directory/pytest can collect from the explicitly requested location instead. If you need to prevent recursion into particular directories as well, use Also note the option is named: not Please mark this answer as accepted if it helped, thank you. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm using
norecursedirsto exclude various subdirectories when pytest searches for test files.However there may be new subdirectories to exclude in future, so i'd prefer to anchor
python_filesat the root of my project (or at the directory containing pytest.ini) so that it will always work without me having to add new exclusions.Is this possible?
For example a syntax like
python_files = ^tests/test_*.pywould be really helpful.Thanks for any suggestions.
[BTW i've tried
testspathsandtestpaths, but they don't seem to avoid the need fornorecursedirs.All reactions