|
oc_chat
|
Classes | |
| class | WalkResult |
Functions | |
| dict | _read_pyproject (Path root) |
| tuple[list[str], str|None] | _read_pytest_ini (Path root) |
| tuple[WalkResult|None, dict|None] | walk_for_package (Path cwd) |
| bool | _matches_any (str name, list[str] patterns) |
| list[Path] | scan_undeclared_roots (Path root, list[Path] declared, str python_files="test_*.py") |
Variables | |
| int | _WALK_LEVELS = 4 |
| tuple | _CONFIG_NAMES = ("pyproject.toml", "pytest.ini") |
| tuple | _BOUNDARY_NAMES = ("pytest.ini", "pyproject.toml", "tox.ini", "setup.cfg") |
| dict | _SKIP_DIR_NAMES = {"__pycache__", "node_modules"} |
| tuple | _CWD_RESOLUTION_MESSAGE |
Single-package fallback discovery + the undeclared-root scan (Plan 184).
Purpose
-------
Implement ADR-T-12 (walk upward from cwd for ``pyproject.toml`` or
``pytest.ini``, cwd plus up to four ancestors; basename package-id with
the ``[tool.oct.test].package_id`` override) and the spec-10 §10
undeclared-root scan that kills the A-18 testpaths trap: a directory
holding test files outside the effective roots is a finding — fatal in
strict, warning in smoke/full.
Responsibilities
----------------
- ``walk_for_package`` — discovery; testpaths from ``pytest.ini`` (or
``[tool.pytest.ini_options]``), package-root fallback when absent.
- ``scan_undeclared_roots`` — the §10 filesystem scan with the
nested-package boundary rule: a directory carrying its own
``pytest.ini``/``pyproject.toml``/``tox.ini``/``setup.cfg`` is a
DIFFERENT package and is skipped, unless a declared root lies within
it (the live-tree shape: the product dir carries ``pyproject.toml``
AND contains the declared roots).
Diagnostics
-----------
Domain: OC_TESTING
Levels:
L2 — lifecycle events
L3 — semantic details
L4 — deep tracing
Contracts
---------
- Discovery is read-only; nothing is created or mutated.
- Hidden directories, ``__pycache__``, and ``node_modules`` are never
scanned.
- The scan honours the package's ``python_files`` pattern (default
``test_*.py``).
Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- oc_chat.testing.report (error constructors)
|
protected |
|
protected |
Parse ``pyproject.toml`` at *root*; empty dict on absence/error.
Definition at line 88 of file package_walk.py.
|
protected |
Return (testpaths, python_files) declared in ``pytest.ini``.
Definition at line 102 of file package_walk.py.
| list[Path] oc_chat.testing.package_walk.scan_undeclared_roots | ( | Path | root, |
| list[Path] | declared, | ||
| str | python_files = "test_*.py" ) |
§10 scan: directories under *root* holding test files outside the *declared* roots. The nested-package boundary rule: a non-root directory carrying its own package config is a different package and is pruned, unless a declared root lies at-or-under it.
Definition at line 186 of file package_walk.py.
| tuple[WalkResult | None, dict | None] oc_chat.testing.package_walk.walk_for_package | ( | Path | cwd | ) |
ADR-T-12 discovery: walk upward from *cwd* for a package config. Returns ``(result, None)`` or ``(None, error)`` where *error* is the ``CWD_RESOLUTION_FAILED`` entry with the pinned message.
Definition at line 121 of file package_walk.py.
|
protected |
Definition at line 65 of file package_walk.py.
|
protected |
Definition at line 64 of file package_walk.py.
|
protected |
Definition at line 68 of file package_walk.py.
|
protected |
Definition at line 66 of file package_walk.py.
|
protected |
Definition at line 62 of file package_walk.py.