"""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()