MCPcopy
hub / github.com/pytest-dev/pytest / test_has_ancestor

Method test_has_ancestor

testing/test_findpaths.py:173–184  ·  view source on GitHub ↗
(self, tmp_path: Path)

Source from the content-addressed store, hash-verified

171
172class TestCommonAncestor:
173 def test_has_ancestor(self, tmp_path: Path) -> None:
174 fn1 = tmp_path / "foo" / "bar" / "test_1.py"
175 fn1.parent.mkdir(parents=True)
176 fn1.touch()
177 fn2 = tmp_path / "foo" / "zaz" / "test_2.py"
178 fn2.parent.mkdir(parents=True)
179 fn2.touch()
180 cwd = Path.cwd()
181 assert get_common_ancestor(cwd, [fn1, fn2]) == tmp_path / "foo"
182 assert get_common_ancestor(cwd, [fn1.parent, fn2]) == tmp_path / "foo"
183 assert get_common_ancestor(cwd, [fn1.parent, fn2.parent]) == tmp_path / "foo"
184 assert get_common_ancestor(cwd, [fn1, fn2.parent]) == tmp_path / "foo"
185
186 def test_single_dir(self, tmp_path: Path) -> None:
187 assert get_common_ancestor(Path.cwd(), [tmp_path]) == tmp_path

Callers

nothing calls this directly

Calls 2

get_common_ancestorFunction · 0.90
mkdirMethod · 0.45

Tested by

no test coverage detected