Verify nesting when a module is within a package. The parent chain should match: Module -> Package -> Session. Session's parent should always be None.
(self, pytester: Pytester)
| 652 | assert parent.config is config |
| 653 | |
| 654 | def test_pkgfile(self, pytester: Pytester) -> None: |
| 655 | """Verify nesting when a module is within a package. |
| 656 | The parent chain should match: Module<x.py> -> Package<subdir> -> Session. |
| 657 | Session's parent should always be None. |
| 658 | """ |
| 659 | tmp_path = pytester.path |
| 660 | subdir = tmp_path.joinpath("subdir") |
| 661 | x = ensure_file(subdir / "x.py") |
| 662 | ensure_file(subdir / "__init__.py") |
| 663 | with subdir.cwd(): |
| 664 | config = pytester.parseconfigure(x) |
| 665 | col = pytester.getnode(config, x) |
| 666 | assert col is not None |
| 667 | assert col.name == "x.py" |
| 668 | assert isinstance(col, pytest.Module) |
| 669 | assert isinstance(col.parent, pytest.Package) |
| 670 | assert isinstance(col.parent.parent, pytest.Session) |
| 671 | # session is batman (has no parents) |
| 672 | assert col.parent.parent.parent is None |
| 673 | for parent in col.listchain(): |
| 674 | assert parent.config is config |
| 675 | |
| 676 | |
| 677 | class Test_genitems: |
nothing calls this directly
no test coverage detected