From bb5fca1a45fc5598464bd86611e31d9d2b4d8233 Mon Sep 17 00:00:00 2001 From: Pastorsimon1798 Date: Tue, 26 May 2026 21:27:39 -0700 Subject: [PATCH 1/4] fix: make PYTHONPATH test assertion repo-name agnostic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test was asserting that PYTHONPATH contains "archaeology" or "DEV-ARCH" — hardcoded local directory names. In CI the repo is cloned as "devarch-framework", so neither substring matched. Replace with an assertion that PYTHONPATH is an absolute path (which is the actual invariant the CLI code guarantees via Path(__file__).parent.parent). Fixes #39 --- tests/test_cli_coverage.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_cli_coverage.py b/tests/test_cli_coverage.py index a5d687c..8fce5bd 100644 --- a/tests/test_cli_coverage.py +++ b/tests/test_cli_coverage.py @@ -397,7 +397,13 @@ def fake_run(cmd, **kwargs): assert db_builder_calls, "db.builder was never invoked" env = db_builder_calls[0]["env"] assert "PYTHONPATH" in env - assert "archaeology" in env["PYTHONPATH"] or "DEV-ARCH" in env["PYTHONPATH"] + # PYTHONPATH is set to the package root (Path(__file__).parent.parent) + # which varies by checkout name — verify it's an absolute path containing + # the archaeology package directory, not a hardcoded repo name. + pp = env["PYTHONPATH"] + assert os.path.isabs(pp.split(":")[0].split(";")[0]), ( + f"PYTHONPATH should start with an absolute path, got: {pp}" + ) # ── analyze (unknown vector) ────────────────────────────────────────────────── From e9fa64e84b97db739568b4491b2812d31a610f0d Mon Sep 17 00:00:00 2001 From: Pastorsimon1798 Date: Wed, 27 May 2026 00:29:25 -0700 Subject: [PATCH 2/4] fix: use os.pathsep in PYTHONPATH test assertion --- tests/test_cli_coverage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cli_coverage.py b/tests/test_cli_coverage.py index 8fce5bd..fc7720a 100644 --- a/tests/test_cli_coverage.py +++ b/tests/test_cli_coverage.py @@ -401,7 +401,7 @@ def fake_run(cmd, **kwargs): # which varies by checkout name — verify it's an absolute path containing # the archaeology package directory, not a hardcoded repo name. pp = env["PYTHONPATH"] - assert os.path.isabs(pp.split(":")[0].split(";")[0]), ( + assert os.path.isabs(pp.split(os.pathsep)[0]), ( f"PYTHONPATH should start with an absolute path, got: {pp}" ) From 0ae3d0c93ffb1925098c4012226a0175a3be709a Mon Sep 17 00:00:00 2001 From: Pastorsimon1798 Date: Wed, 27 May 2026 00:37:55 -0700 Subject: [PATCH 3/4] test: assert build-db PYTHONPATH uses package root --- tests/test_cli_coverage.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_cli_coverage.py b/tests/test_cli_coverage.py index fc7720a..c8825a9 100644 --- a/tests/test_cli_coverage.py +++ b/tests/test_cli_coverage.py @@ -14,6 +14,7 @@ import pytest from click.testing import CliRunner +import archaeology.cli as cli from archaeology.cli import main @@ -397,13 +398,11 @@ def fake_run(cmd, **kwargs): assert db_builder_calls, "db.builder was never invoked" env = db_builder_calls[0]["env"] assert "PYTHONPATH" in env - # PYTHONPATH is set to the package root (Path(__file__).parent.parent) - # which varies by checkout name — verify it's an absolute path containing - # the archaeology package directory, not a hardcoded repo name. + # PYTHONPATH is set to the package root (Path(__file__).parent.parent). + # Verify that exact path without relying on checkout-specific repo names. pp = env["PYTHONPATH"] - assert os.path.isabs(pp.split(os.pathsep)[0]), ( - f"PYTHONPATH should start with an absolute path, got: {pp}" - ) + expected_pkg_root = str(Path(cli.__file__).parent.parent) + assert pp.split(os.pathsep)[0] == expected_pkg_root # ── analyze (unknown vector) ────────────────────────────────────────────────── From c1e8393dc3d2d441e0948f580f5e3dac8a801465 Mon Sep 17 00:00:00 2001 From: Pastorsimon1798 Date: Wed, 27 May 2026 01:14:40 -0700 Subject: [PATCH 4/4] fix: use os.pathsep when appending PYTHONPATH --- archaeology/cli.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/archaeology/cli.py b/archaeology/cli.py index 5242b07..18cba43 100644 --- a/archaeology/cli.py +++ b/archaeology/cli.py @@ -83,7 +83,7 @@ def demo(project_name, force, build_db): cmd = [sys.executable, "-m", "archaeology.db.builder", "--project-root", str(project_root)] _env = os.environ.copy() _pkg_root = str(Path(__file__).parent.parent) - _env["PYTHONPATH"] = _pkg_root + ((":" + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "") + _env["PYTHONPATH"] = _pkg_root + ((os.pathsep + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "") result = subprocess.run(cmd, check=True, timeout=300, env=_env) if result.returncode != 0: raise click.exceptions.Exit(result.returncode) @@ -143,7 +143,7 @@ def build_db(project_name, verbose): _env = os.environ.copy() _pkg_root = str(Path(__file__).parent.parent) - _env["PYTHONPATH"] = _pkg_root + ((":" + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "") + _env["PYTHONPATH"] = _pkg_root + ((os.pathsep + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "") result = subprocess.run(cmd, check=True, timeout=300, env=_env) if result.returncode == 0 and os.path.exists(db_path): click.echo(f"Database built at {db_path}") @@ -658,7 +658,7 @@ def cascade(project_name, dry_run, skip_mine): "--project-root", str(project_dir)] _env = os.environ.copy() _pkg_root = str(Path(__file__).parent.parent) - _env["PYTHONPATH"] = _pkg_root + ((":" + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "") + _env["PYTHONPATH"] = _pkg_root + ((os.pathsep + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "") result = subprocess.run(cmd, capture_output=True, text=True, timeout=300, env=_env) if result.returncode == 0: click.echo(f" Database built ({db_path})") @@ -993,7 +993,7 @@ def sync(projects, skip_mine, skip_signals, verbose): _env = os.environ.copy() _pkg_root = str(Path(__file__).parent.parent) - _env["PYTHONPATH"] = _pkg_root + ((":" + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "") + _env["PYTHONPATH"] = _pkg_root + ((os.pathsep + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "") result = subprocess.run(cmd, capture_output=not verbose, check=True, timeout=300, env=_env) if result.returncode == 0 and os.path.exists(db_path): click.echo(f" DB built")