8OI-521 regression coverage — ``oct.deps.oct_deps.build_dependency_graph``
9must key modules by their dotted import path (``pkg.sub.module``) rather
10than the bare file stem (``module``). The old behaviour silently dropped
11every occurrence of a repeated stem on top of a single graph entry,
12hiding both modules and their dependencies.
16- Verify ``module_name_for`` returns the dotted import path.
17- Verify ``__init__.py`` resolves to its parent package's dotted name.
18- Verify two files with the same stem in different packages produce
26 L3 — assertion details
31- ``module_name_for(py_file, root)`` returns the dotted path.
32- ``__init__.py`` resolves to its parent package's dotted name.
33- Two files with the same stem in different packages both appear in the
34 graph with distinct dotted keys (no collision).
37from __future__
import annotations
39from pathlib
import Path
47 """OI-521: a module two packages deep gets a three-segment dotted key."""
48 (tmp_path /
"pkg" /
"sub").mkdir(parents=
True)
49 module = tmp_path /
"pkg" /
"sub" /
"util.py"
50 module.write_text(
"", encoding=
"utf-8")
51 assert module_name_for(module, tmp_path) ==
"pkg.sub.util"
55 """OI-521: ``pkg/__init__.py`` resolves to the package name ``pkg``."""
56 (tmp_path /
"pkg").mkdir()
57 init = tmp_path /
"pkg" /
"__init__.py"
58 init.write_text(
"", encoding=
"utf-8")
59 assert module_name_for(init, tmp_path) ==
"pkg"
63 """Two ``util.py`` files in different packages both land in the graph."""
71 (tmp_path /
"pkg_a").mkdir()
72 (tmp_path /
"pkg_a" /
"__init__.py").write_text(
"", encoding=
"utf-8")
73 (tmp_path /
"pkg_a" /
"util.py").write_text(src, encoding=
"utf-8")
75 (tmp_path /
"pkg_b").mkdir()
76 (tmp_path /
"pkg_b" /
"__init__.py").write_text(
"", encoding=
"utf-8")
77 (tmp_path /
"pkg_b" /
"util.py").write_text(src, encoding=
"utf-8")
79 graph = build_dependency_graph(tmp_path)
81 assert "pkg_a.util" in graph
82 assert "pkg_b.util" in graph
84 assert "util" not in graph
None test_module_name_for_nested_module(Path tmp_path)
None test_build_dependency_graph_no_stem_collision(Path tmp_path)
None test_module_name_for_init_collapses_to_package(Path tmp_path)