. └── root ├── Test_root.py ├── __init__.py ├── sub1 │ ├── Test_sub1.py │ └── __init__.py └── sub2 └── test └── test_sub2.py
(pytester: Pytester)
| 1457 | |
| 1458 | |
| 1459 | def test_package_ordering(pytester: Pytester) -> None: |
| 1460 | """ |
| 1461 | . |
| 1462 | └── root |
| 1463 | ├── Test_root.py |
| 1464 | ├── __init__.py |
| 1465 | ├── sub1 |
| 1466 | │ ├── Test_sub1.py |
| 1467 | │ └── __init__.py |
| 1468 | └── sub2 |
| 1469 | └── test |
| 1470 | └── test_sub2.py |
| 1471 | |
| 1472 | """ |
| 1473 | pytester.makeini( |
| 1474 | """ |
| 1475 | [pytest] |
| 1476 | python_files=*.py |
| 1477 | """ |
| 1478 | ) |
| 1479 | root = pytester.mkpydir("root") |
| 1480 | sub1 = root.joinpath("sub1") |
| 1481 | sub1.mkdir() |
| 1482 | sub1.joinpath("__init__.py").touch() |
| 1483 | sub2 = root.joinpath("sub2") |
| 1484 | sub2_test = sub2.joinpath("test") |
| 1485 | sub2_test.mkdir(parents=True) |
| 1486 | |
| 1487 | root.joinpath("Test_root.py").write_text("def test_1(): pass") |
| 1488 | sub1.joinpath("Test_sub1.py").write_text("def test_2(): pass") |
| 1489 | sub2_test.joinpath("test_sub2.py").write_text("def test_3(): pass") |
| 1490 | |
| 1491 | # Execute from . |
| 1492 | result = pytester.runpytest("-v", "-s") |
| 1493 | result.assert_outcomes(passed=3) |
nothing calls this directly
no test coverage detected