Skip to main content

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 uv or pip 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:
    • pytest
    • inline-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

  1. Open Command Palette → Preferences: Open Keyboard Shortcuts (JSON).
  2. Copy the contents of template_keybindings.json into the file and save.

VSCode’s keybindings file supports comments (JSONC). You can keep the comments.

Task

  1. For a workspace task: open .vscode/tasks.json (create if missing) and copy from template_tasks.json.
  2. 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 pytest and inline-snapshot are 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)

Source distribution for vscode-pytest-update-snapshot 0.3.0
File Size Uploaded
vscode_pytest_update_snapshot-0.3.0.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vscode-pytest-update-snapshot 0.3.0
File Interpreter ABI Platform
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}

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page