Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pytest-textual-snapshot #28779

Merged
merged 13 commits into from
Jan 20, 2025
50 changes: 50 additions & 0 deletions recipes/pytest-textual-snapshot/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{% set name = "pytest-textual-snapshot" %}
{% set version = "1.0.0" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
url: https://pypi.org/packages/source/{{ name[0] }}/{{ name | replace("-", "_") }}/{{ name | replace("-", "_") }}-{{ version }}.tar.gz
sha256: 065217055ed833b8a16f2320a0613f39a0154e8d9fee63535f29f32c6414b9d7

build:
noarch: python
number: 0
script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation

requirements:
host:
- python {{ python_min }}
- pip
- poetry-core >=1.0.0
run:
- python >={{ python_min }}
- pytest >=8.0.0
- rich >=12.0.0
- textual >=0.28.0
- syrupy 4.8.0
- jinja2 >=3.0.0

test:
commands:
- python test.py
files:
- test.py
requires:
- python {{ python_min }}

about:
home: https://github.com/Textualize/pytest-textual-snapshot
summary: A pytest plugin for snapshot testing Textual applications.
description: |
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.
license: MIT
license_file: LICENSE

extra:
recipe-maintainers:
- claudiushaag
12 changes: 12 additions & 0 deletions recipes/pytest-textual-snapshot/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import subprocess

def check_plugin_in_trace_config():
# Run pytest with --trace-config to get configuration info
result = subprocess.run(['pytest', '--trace-config'], capture_output=True, text=True)

# Check if the textual-snapshot plugin is in the output
if "textual-snapshot" not in result.stdout:
raise RuntimeError("The 'textual-snapshot' plugin is not loaded. ")

# Run the check
check_plugin_in_trace_config()
Loading