Verify nesting when a module is within a package. The parent chain should match: Module<x.py> -> Package<subdir> -> Session. Session's parent should always be None.
(self, pytester: Pytester, monkeypatch: MonkeyPatch)
| 699 | assert parent.config is config |
| 700 | |
| 701 | def test_pkgfile(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> None: |
| 702 | """Verify nesting when a module is within a package. |
| 703 | The parent chain should match: Module<x.py> -> Package<subdir> -> Session. |
| 704 | Session's parent should always be None. |
| 705 | """ |
| 706 | tmp_path = pytester.path |
| 707 | subdir = tmp_path.joinpath("subdir") |
| 708 | x = ensure_file(subdir / "x.py") |
| 709 | ensure_file(subdir / "__init__.py") |
| 710 | with monkeypatch.context() as mp: |
| 711 | mp.chdir(subdir) |
| 712 | config = pytester.parseconfigure(x) |
| 713 | col = pytester.getnode(config, x) |
| 714 | assert col is not None |
| 715 | assert col.name == "x.py" |
| 716 | assert isinstance(col, pytest.Module) |
| 717 | assert isinstance(col.parent, pytest.Package) |
| 718 | assert isinstance(col.parent.parent, pytest.Session) |
| 719 | # session is batman (has no parents) |
| 720 | assert col.parent.parent.parent is None |
| 721 | for parent in col.listchain(): |
| 722 | assert parent.config is config |
| 723 | |
| 724 | |
| 725 | class Test_genitems: |
nothing calls this directly
no test coverage detected