Snapshot testing for Textual apps
Project description
pytest-textual-snapshot
Snapshot testing for Textual apps.
Installation
Install using pip:
pip install pytest-textual-snapshot
After installing, the snap_compare fixture will automatically be made available.
About
A pytest-textual-snapshot test saves an SVG screenshot of a running Textual app to disk.
The next time the test runs, it takes another screenshot and compares it to the saved one.
If the new screenshot differs from the old one, the test fails.
This is a convenient way to quickly and automatically detect visual regressions in your applications.
Usage
Running tests
You can run your tests using pytest as normal.
My snapshot test failed, what do I do?
If your snapshot test fails, it means that the screenshot taken during the test session differs from the last screenshot taken. This change is shown in the failure report, which you'll be given a linked to in the event of a failure.
If the diff shown in the failure report looks correct, you can update the snapshot on disk
by running pytest with the --snapshot-update flag.
Writing tests
Basic usage
Inject the snap_compare fixture into your test and call
it with the path to the Textual app (the file containing the App subclass).
def test_something(snap_compare):
assert snap_compare("path/to/app.py")
Pressing keys
Key presses can be simulated before the screenshot is taken.
def test_something(snap_compare):
assert snap_compare("path/to/app.py", press=["tab", "left", "a"])
Project details
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 pytest_textual_snapshot-0.2.0.tar.gz.
File metadata
- Download URL: pytest_textual_snapshot-0.2.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.11.1 Darwin/22.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e9f8c4b1b011bdae67d4f1129530afd6611f3f8bcf03cf06699402179bc12cf
|
|
| MD5 |
c12ba8eda50dc09abe227b396bfc94da
|
|
| BLAKE2b-256 |
d99c4e75a6b4de089e48da47858d0cdc2fa47289efcbc42410706f896b98c96a
|
File details
Details for the file pytest_textual_snapshot-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pytest_textual_snapshot-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.11.1 Darwin/22.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
663fe07bf62181ec0c63139daaeaf50eb8088164037eb30d721f028adc9edc8c
|
|
| MD5 |
395a8390776276fa3bbe83e62a29fada
|
|
| BLAKE2b-256 |
1d4105e319a77aca9db6675e3d20785985aa236f247afdae9c452dca40868f27
|