(self, pytester: Pytester)
| 71 | assert pytester.collect_by_name(modcol, "doesnotexist") is None |
| 72 | |
| 73 | def test_getparent_and_accessors(self, pytester: Pytester) -> None: |
| 74 | modcol = pytester.getmodulecol( |
| 75 | """ |
| 76 | class TestClass: |
| 77 | def test_foo(self): |
| 78 | pass |
| 79 | """ |
| 80 | ) |
| 81 | cls = pytester.collect_by_name(modcol, "TestClass") |
| 82 | assert isinstance(cls, pytest.Class) |
| 83 | fn = pytester.collect_by_name(cls, "test_foo") |
| 84 | assert isinstance(fn, pytest.Function) |
| 85 | |
| 86 | assert fn.getparent(pytest.Module) is modcol |
| 87 | assert modcol is not None |
| 88 | assert modcol.module is not None |
| 89 | assert modcol.cls is None |
| 90 | assert modcol.instance is None |
| 91 | |
| 92 | assert fn.getparent(pytest.Class) is cls |
| 93 | assert cls.module is not None |
| 94 | assert cls.cls is not None |
| 95 | assert cls.instance is None |
| 96 | |
| 97 | assert fn.getparent(pytest.Function) is fn |
| 98 | assert fn.module is not None |
| 99 | assert fn.cls is not None |
| 100 | assert fn.instance is not None |
| 101 | assert fn.function is not None |
| 102 | |
| 103 | def test_getcustomfile_roundtrip(self, pytester: Pytester) -> None: |
| 104 | hello = pytester.makefile(".xxx", hello="world") |
nothing calls this directly
no test coverage detected