Load the host modules when the registry reads ats.py by path without the repo root on sys.path
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7f04c10e9e
commit
4fb06191cf
4 files changed
+38
-7
No files matched your search
@@ -6,6 +6,8 @@ a fake host stands in where a behaviour belongs to no real host yet."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import types
|
||||
from collections.abc import Callable
|
||||
@@ -63,6 +65,22 @@ def parse(body, slug): return []
|
||||
"""
|
||||
|
||||
|
||||
def test_the_registry_loads_ats_by_path_without_the_repo_root_on_the_path(
|
||||
tmp_path: Path) -> None:
|
||||
"""As `desk.sources.registry` does in a process the app did not set up:
|
||||
another working directory, and `plugins` not importable at first."""
|
||||
code = (
|
||||
"import importlib.util, sys\n"
|
||||
"assert importlib.util.find_spec('plugins') is None, 'plugins is importable'\n"
|
||||
"from desk.sources import registry\n"
|
||||
f"print(sorted(registry.available([{str(ROOT / 'plugins')!r}])))\n")
|
||||
env = {k: v for k, v in os.environ.items() if k != "PYTHONPATH"}
|
||||
done = subprocess.run([sys.executable, "-c", code], cwd=tmp_path, env=env,
|
||||
capture_output=True, text=True, timeout=60, check=False)
|
||||
assert done.returncode == 0, done.stderr
|
||||
assert "'ats'" in done.stdout and "'search'" in done.stdout
|
||||
|
||||
|
||||
def test_the_registry_loads_a_package_by_name_and_skips_private_modules(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
path = _package(tmp_path, monkeypatch, "hostsok", {
|
||||
|
||||
Reference in new issue
Block a user