PyTest test discovery
Running pytest will find test files and in the files test functions.
- test_*.py files
- *_test.py files
- test_* functions
- TestSomething class
- test_* methods
examples/pytest/discovery
.
├── db
│ └── test_db.py
├── other_file.py
├── test_one.py
└── two_test.py
============================= test session starts ==============================
platform linux -- Python 3.8.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1 -- /home/gabor/venv3/bin/python
cachedir: .pytest_cache
plugins: json-report-1.2.4, random-order-1.0.4, flake8-1.0.6, forked-1.3.0, dash-1.17.0, metadata-1.11.0, xdist-2.2.1
collecting ... collected 3 items
test_one.py::test_1 PASSED [ 33%]
two_test.py::test_2 PASSED [ 66%]
db/test_db.py::test_db PASSED [100%]
============================== 3 passed in 0.02s ===============================