September 2017
Intermediate to advanced
222 pages
5h 1m
English
Whereas norecursedirs tells pytest where not to look, testpaths tells pytest where to look. testspaths is a list of directories relative to the root directory to look in for tests. It’s only used if a directory, file, or nodeid is not given as an argument.
Suppose for the Tasks project we put pytest.ini in the tasks_proj directory instead of under tests:
| | tasks_proj/ |
| | ├── pytest.ini |
| | ├── src |
| | │ └── tasks |
| | │ ├── api.py |
| | │ └── ... |
| | └── tests |
| | ├── conftest.py |
| | ├── func |
| | │ ├── __init__.py |
| | │ ├── test_add.py |
| | │ ├── ... |
| | └── unit |
| | ├── __init__.py |
| | ├── test_task.py |
| | └── ... |
It could then make sense to put tests in testpaths:
| | [pytest] |
| | testpaths = tests |
Now, as long as you start pytest from ...
Read now
Unlock full access