test: keep subprocess imports on the active worktree

This commit is contained in:
阿白叔 committed 2026-11-17 00:39:29 +08:00
1 parent eabf61c73b
commit 5b7e7bea2f
3 files changed
+26 -1

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
"""A spawned Python must test the same worktree as its pytest parent."""
import json
from pathlib import Path
import subprocess
import sys
def test_spawned_python_imports_active_worktree_from_another_directory(tmp_path):
import cbb_refresh_verify
child = subprocess.run(
[sys.executable, '-c', 'import json,cbb_refresh_verify; '
'print(json.dumps(cbb_refresh_verify.__file__))'],
cwd=tmp_path, capture_output=True, text=True, check=True, timeout=10)
assert Path(json.loads(child.stdout)).resolve() == Path(cbb_refresh_verify.__file__).resolve()