8Validate the OI-426 recursive package discovery in
9``oct.docs.oct_docs._find_packages``.
13- Confirm depth-1 and depth-2 cases continue to work (backward compat).
14- Confirm depth-3+ cases now resolve (new capability).
15- Confirm walker stops at the first ``__init__.py`` (autodoc handles descent).
16- Confirm ``LINTER_EXCLUDE_DIRS`` / ``WILDCARD_EXCLUDE_DIRS`` are respected.
17- Confirm the ``_MAX_PACKAGE_DEPTH`` safety cap prevents runaway walks.
18- Confirm the explicit ``autodoc_modules`` override path is unchanged.
29Inputs: tmp_path pytest fixture
30Outputs: pass/fail assertions
33from pathlib
import Path
41 path.mkdir(parents=
True, exist_ok=
True)
42 (path /
"__init__.py").write_text(
"", encoding=
"utf-8")
46 """Backward compat: a top-level package is discovered."""
49 result = _find_packages(tmp_path, {})
51 assert result == [(
"pkg", tmp_path /
"pkg")]
55 """Backward compat: ``oct/oct/__init__.py`` resolves to the inner dir."""
56 inner = tmp_path /
"oct" /
"oct"
59 result = _find_packages(tmp_path, {})
61 assert result == [(
"oct", inner)]
65 """New capability: ``src/mypkg/__init__.py`` is now discovered."""
66 inner = tmp_path /
"src" /
"mypkg"
69 result = _find_packages(tmp_path, {})
71 assert result == [(
"mypkg", inner)]
75 """Subpackages under a discovered package must not be listed."""
77 _mkpkg(tmp_path /
"pkg" /
"sub")
79 result = _find_packages(tmp_path, {})
81 assert result == [(
"pkg", tmp_path /
"pkg")]
85 """Hidden / excluded directories are skipped."""
86 _mkpkg(tmp_path /
".git" /
"fake")
89 result = _find_packages(tmp_path, {})
91 assert result == [(
"real", tmp_path /
"real")]
95 """A 15-deep empty tree returns [] and does not raise."""
98 deep = deep / f
"level{i}"
99 deep.mkdir(parents=
True)
101 result = _find_packages(tmp_path, {})
104 assert _MAX_PACKAGE_DEPTH == 10
108 """Explicit ``autodoc_modules`` config bypasses the walker."""
109 _mkpkg(tmp_path /
"hidden")
110 _mkpkg(tmp_path /
"chosen")
112 result = _find_packages(
113 tmp_path, {
"autodoc_modules": [
"chosen"]},
116 assert result == [(
"chosen", tmp_path /
"chosen")]
120 """Multiple top-level packages are all discovered."""
125 result = _find_packages(tmp_path, {})
126 names = sorted(name
for name, _
in result)
128 assert names == [
"a",
"b",
"c"]
None test_find_packages_max_depth_safety(Path tmp_path)
None test_find_packages_respects_exclusions(Path tmp_path)
None test_find_packages_autodoc_modules_override(Path tmp_path)
None test_find_packages_stops_at_package(Path tmp_path)
None test_find_packages_depth_2_nested_project(Path tmp_path)
None test_find_packages_depth_1(Path tmp_path)
None test_find_packages_multiple_siblings(Path tmp_path)
None test_find_packages_depth_3_src_layout(Path tmp_path)