VS Code / Cursor extension that statically resolves pathlib.Path expressions in pytest test files to actual file paths.
Right-click on a Path expression in a pytest test file and select "Open Resolved Test Path" to open the resolved file or directory.
Pattern A: Fixture chain + class attribute + string literal
# conftest.py
@pytest.fixture(scope="session")
def data_root_path(request) -> Path:
return request.config.rootpath / "tests" / "module_a" / "data"
# test_example.py
@pytest.fixture()
def data_path(data_root_path: Path) -> Path:
return data_root_path / "sub" / "test_example"
class TestExample:
_data_dir = "TestExample"
def test_case(self, data_path: Path) -> None:
d = data_path / self._data_dir / "case1" # <- resolves herePattern B: Local variable reuse
d = data_path / self._data_dir / "test_case"
result = read_data(d / "input.csv") # <- resolves herePattern C: request.config.rootpath resolution
@pytest.fixture(scope="session")
def data_root_path(request) -> Path:
return request.config.rootpath / "tests" / "data" # <- resolves to workspace root- Build the package (see Development below)
- In VS Code / Cursor:
Extensions>...>Install from VSIX... - Select the generated
.vsixfile
- Open a pytest test file (file path must contain
tests/) - Place your cursor on a
Pathexpression (e.g.,d / "input.csv") - Right-click and select "Open Resolved Test Path"
- The resolved file or directory will open
| Setting | Default | Description |
|---|---|---|
pytestPathResolver.pythonPath |
python3 |
Path to Python interpreter |
pytestPathResolver.timeout |
5000 |
Timeout for Python subprocess (ms) |
- Node.js 22+
- Python 3.11+
- pnpm
- uv
pnpm install
uv syncnpx tsc -p ./uv run ruff check python/ python_tests/
uv run ruff format python/ python_tests/uv run pytest python_tests/ -v- Open this project in VS Code / Cursor
- Press F5 to launch the Extension Development Host
- Open a project with pytest test files in the new window
npx @vscode/vsce package --no-dependencies --allow-missing-repositorysrc/ # TypeScript (VS Code extension)
extension.ts # Extension entry point
pythonBridge.ts # Spawns Python subprocess
pathResolver.ts # Handles resolve results (open file/directory)
types.ts # Shared type definitions
python/ # Python (static analysis)
ast_parser.py # AST parsing: extracts Path segments from source
fixture_resolver.py # Resolves pytest fixtures across conftest.py chain
path_evaluator.py # Orchestrator: combines parser + resolver
resolve_path.py # CLI entry point (JSON stdin/stdout)
MIT