Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
test(workspace): ceiling the workspace walk inside unit tests (#3417)
ump45nose2451c1c9e049
diff --git a/packages/core/src/repowise/core/workspace/config.py b/packages/core/src/repowise/core/workspace/config.pyindex 943880ebe..20332ea4e 100644--- a/packages/core/src/repowise/core/workspace/config.py+++ b/packages/core/src/repowise/core/workspace/config.py@@ -7,6 +7,7 @@ Pure data module with no CLI or DB dependencies. Handles thefrom __future__ import annotationsimport logging+import osfrom dataclasses import dataclass, fieldfrom pathlib import Pathfrom typing import Any@@ -20,6 +21,11 @@ _log = logging.getLogger("repowise.workspace.config")# ---------------------------------------------------------------------------WORKSPACE_CONFIG_FILENAME = ".repowise-workspace.yaml"++# Upper bound for the workspace walk in find_workspace_root, set by the test+# suite so unit tests never discover the developer's real workspace above+# their tmp_path (GIT_CEILING_DIRECTORIES-style).+WORKSPACE_CEILING_ENV_VAR = "REPOWISE_WORKSPACE_CEILING"WORKSPACE_DATA_DIR = ".repowise-workspace"CURRENT_VERSION = 1@@ -399,12 +405,18 @@ def find_workspace_root(start: Path | None = None) -> Path | None:"""Walk up from *start* (default: cwd) looking for ``.repowise-workspace.yaml``.Returns the directory containing the file, or ``None`` if not found.- Stops at the filesystem root.+ Stops at the filesystem root, or at the directory named by the+ ``REPOWISE_WORKSPACE_CEILING`` environment variable: the ceiling+ directory itself is still checked, but the walk does not ascend past it."""+ ceiling = os.environ.get(WORKSPACE_CEILING_ENV_VAR)+ ceiling_dir = Path(ceiling).resolve() if ceiling else Nonecurrent = (start or Path.cwd()).resolve()while True:if (current / WORKSPACE_CONFIG_FILENAME).is_file():return current+ if ceiling_dir is not None and current == ceiling_dir:+ return None # ceiling: the directory itself was checkedparent = current.parentif parent == current:return None # reached filesystem rootdiff --git a/tests/conftest.py b/tests/conftest.pyindex 3dc068d5e..ba7bba0c9 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -9,6 +9,21 @@ from pathlib import Pathimport pytest[email protected](autouse=True)+def _ceiling_workspace_walk(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):+ """Keep the workspace walk inside each test's tmp_path.++ ``find_workspace_root`` walks up to the filesystem root, so a tmp_path+ that sits below a directory holding ``.repowise-workspace.yaml`` (say+ ``~/work/.tmp``) makes unit tests find the developer's real workspace+ instead of none. Ceiling the walk at tmp_path: the directory itself is+ still checked, so workspaces a test creates inside it keep working.+ """+ from repowise.core.workspace.config import WORKSPACE_CEILING_ENV_VAR++ monkeypatch.setenv(WORKSPACE_CEILING_ENV_VAR, str(tmp_path))++@pytest.fixture(scope="session", autouse=True)def _no_telemetry_network(tmp_path_factory: pytest.TempPathFactory):"""Guarantee no test emits telemetry over the network or into real state.diff --git a/tests/unit/precedent/test_transcript_episodes.py b/tests/unit/precedent/test_transcript_episodes.pyindex f4aad47d2..2c8603da4 100644--- a/tests/unit/precedent/test_transcript_episodes.py+++ b/tests/unit/precedent/test_transcript_episodes.py@@ -8,6 +8,7 @@ run that read nothing is allowed to delete.from __future__ import annotations+import calendarimport jsonimport time@@ -502,8 +503,7 @@ def test_the_episode_is_dated_from_the_session_not_the_index(tmp_path):(row,) = _rows(root, tier=TIER_TRANSCRIPT)assert row["birth_at"] == pytest.approx(- time.mktime(time.strptime("2026-08-06 10:00:00", "%Y-%m-%d %H:%M:%S"))- - time.timezone,+ calendar.timegm(time.strptime("2026-08-06 10:00:00", "%Y-%m-%d %H:%M:%S")),abs=2,)assert row["tier"] == TIER_TRANSCRIPT