Test Overview
This test checks that pytest only runs tests located in the specified testpaths directory. It verifies that tests outside this directory are not executed.
This test checks that pytest only runs tests located in the specified testpaths directory. It verifies that tests outside this directory are not executed.
import pytest def test_included_path(): assert True # pytest.ini content: # [pytest] # testpaths = tests # Directory structure: # /project # /tests # test_included.py (contains test_included_path) # /other # test_excluded.py (contains test_excluded_path) # Run command: # pytest # Expected: Only test_included_path runs and passes, test_excluded_path is not collected.
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Pytest starts test discovery | Pytest reads pytest.ini and finds testpaths = tests | - | PASS |
| 2 | Pytest searches only inside the 'tests' directory for test files | Only test_included.py is found and collected | - | PASS |
| 3 | Pytest runs test_included_path() | Test function executes and returns True | assert True passes | PASS |
| 4 | Pytest ignores test_excluded.py outside 'tests' directory | test_excluded_path() is not collected or run | No assertion for excluded test as it is not run | PASS |
| 5 | Pytest finishes test run and reports results | Report shows 1 test collected and passed | Test count matches expected collected tests | PASS |