vscode-pytest-update-snapshot
Run pytest on the test under your cursor and update inline snapshots (VSCode-friendly).
Install / Run (no install with uvx)
uvx vscode-pytest-update-snapshot tests/test_example.py 12
# ensure it uses your project venv interpreter:
uvx --python ".venv/Scripts/python.exe" vscode-pytest-update-snapshot tests/test_example.py 12
Pass extra pytest args after --:
uvx vscode-pytest-update-snapshot tests/test_example.py 12 -- -q -k "mycase"
Requirements
- Python 3.10+ (tested on 3.12)
- uv installed on your PATH (
pipx install uvorpip install uvtools—use your preferred method) - A project virtual environment selected in VSCode (bottom-right status bar → Select Interpreter)
- These packages installed in your project venv:
pytestinline-snapshot(with Ruff formatting, see config below)ruff
Install with uv:
uv add pytest ruff inline-snapshot --dev
Inline-snapshot formatting via Ruff
Add this to your pyproject.toml:
[tool.inline-snapshot]
# Format with Ruff; read/write via stdin/stdout so inline-snapshot can capture it
format-command = "ruff format --stdin-filename {filename}"
[tool.ruff]
line-length = 100
target-version = "py312"
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
docstring-code-format = true
[tool.pytest.ini_options]
addopts = "-q"
testpaths = ["tests"]
VSCode setup
This repo includes templates for a handy “Update snapshot (test at cursor)” action.
Keybinding
- Open Command Palette → Preferences: Open Keyboard Shortcuts (JSON).
- Copy the contents of
template_keybindings.jsoninto the file and save.
VSCode’s keybindings file supports comments (JSONC). You can keep the comments.
Task
- For a workspace task: open
.vscode/tasks.json(create if missing) and copy fromtemplate_tasks.json. - For a profile-level (user) task: Command Palette → Tasks: Open User Tasks, then paste the task there.
Either way, VSCode tasks also support comments (JSONC).
Run it
- Put the cursor on a test line in a Python file.
- Press the configured shortcut (default
Ctrl+Alt+U) or run Terminal → Run Task → Update snapshot (test at cursor). - Make sure your interpreter/venv is selected in the VSCode status bar so
pytestandinline-snapshotare found.
Install this CLI (editable during development)
uv pip install -e .
(or publish and use uvx, but for local dev the editable install is simplest.)
Metadata
Release files for vscode-pytest-update-snapshot 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vscode_pytest_update_snapshot-0.3.0.tar.gz | 7.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vscode_pytest_update_snapshot-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.4 kB
Release files / vscode_pytest_update_snapshot-0.3.0.tar.gz
| Download URL | vscode_pytest_update_snapshot-0.3.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53be0f2542d74e72054388188c0a2f613f920e713fe1dfda6ab3883fbf35bed2
|
|
BLAKE2b-256 checksum How to use checksums |
471c2e5d9d2ca25f2933503b34c4264a35e1eda9a829e785fe2c052a6350e2c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / vscode_pytest_update_snapshot-0.3.0-py3-none-any.whl
| Download URL | vscode_pytest_update_snapshot-0.3.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed7bca2ae2faf451ac34af221eb23542fd2aa42b09d5dce0937e7be699b640f6
|
|
BLAKE2b-256 checksum How to use checksums |
0d1bd6f2f95ed6ced63afbd10b02992c543d715ac5a4a111c6a8ed225161db50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|