Registry / testing / pytest-textual-snapshot

pytest-textual-snapshot

JSON →
library1.1.0pypypi✓ verified 85d ago

Snapshot testing plugin for pytest that enables visual regression testing of Textual terminal applications. Version 1.1.0 requires Python >=3.8.1, <4.0.0. Regular releases.

pip install pytest-textual-snapshot
INSTALL
IMPORT
SIG · PYTEST-TEXTUAL-SNA
P
pytest-textual-snapshot
testingpythonv1.1.0
Install
4.8s avg
Import
Disk
43MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 43.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.8s · import 0.000s · 44MB
43MB installed
● package 43MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SnapshotAssertion
from pytest_textual_snapshot import SnapshotAssertion
from pytest_textual_snapshot import snapshot_app
SingleFileSnapshotExtension
from pytest_textual_snapshot import SingleFileSnapshotExtension
SvgSnapshotDiff
from pytest_textual_snapshot import SvgSnapshotDiff

Minimal test using the snapshot_app fixture to capture a Textual app's render.

import pytest from textual.app import App, ComposeResult from textual.widgets import Static from pytest_textual_snapshot import snapshot_app class SimpleApp(App): def compose(self) -> ComposeResult: yield Static("Hello, World!") def test_snapshot(snapshot_app): app = SimpleApp() async with app.run_test() as pilot: # Use snapshot_app fixture to capture the app's render snapshot_app(app)
Debug
Known issues
gotchaThe snapshot_app fixture must be used within an async context (e.g., app.run_test()) otherwise it will fail.
fix
Ensure the test is async and uses `async with app.run_test() as pilot:` before calling snapshot_app.
affects: >=1.0.0
gotchaSnapshots are stored as SVG files in a `__snapshots__` directory. If the test environment differs (e.g., different terminal width), snapshots may mismatch.
fix
Set fixed terminal dimensions in your test using `app.run_test(size=(80, 24))` to ensure reproducibility.
affects: >=1.0.0
Upgrade
Version history
1.1.0latest on PyPI · released Jan 23, 2025
Audit
Dependencies
pytestrequiredPlugin requires pytest to run.
textualrequiredPlugin requires Textual framework to snapshot applications.
Agent activity
9 hits · last 30 days
node
8
Resources
pytest-textual-snapshot — pip install pytest-textual-snapshot · libregistry