Run pytest on the test at cursor and update inline snapshots.
Project description
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.)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vscode_pytest_update_snapshot-0.2.0.tar.gz.
File metadata
- Download URL: vscode_pytest_update_snapshot-0.2.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
151de3a39f070f177d76ceaa30d5b8995838a52102759210f7e82460160fce25
|
|
| MD5 |
74c39af19b92e5cdfae00c342e0ade61
|
|
| BLAKE2b-256 |
6d1e2da4b11f500d39d62aa6f0888c015a51ac4135de241cc390177f888f4334
|
File details
Details for the file vscode_pytest_update_snapshot-0.2.0-py3-none-any.whl.
File metadata
- Download URL: vscode_pytest_update_snapshot-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3c2de5fe09ee372fd9814001df1ef65d6dd0a3546b9b82b61689b9c0d62e453
|
|
| MD5 |
7a101bdc1b570c9d279c6b31d9632ed4
|
|
| BLAKE2b-256 |
cae34f61290ce2febf15fd0e244b61ab71166139905defcf764331292b8a86ec
|