diff --git a/.gitignore b/.gitignore index 7df2008..f314e60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ +# pytest-textual-snapshot +snapshot_report.html + + # Temporary backup files from Textual Paint and other editors *~ diff --git a/cspell.json b/cspell.json index 0b38051..2fbc9c8 100644 --- a/cspell.json +++ b/cspell.json @@ -123,6 +123,7 @@ "pyperclip", "pypixelart", "pyright", + "pytest", "pyxdg", "qualname", "rasterization", diff --git a/requirements.txt b/requirements.txt index ae6e379..d0fad9c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,3 +12,5 @@ textual[dev]==0.28.0 watchdog==3.0.0 # for development; optional (only used when --restart-on-changes is passed) types-Pillow==10.0.0.1 # for development types-psutil==5.9.5.15 # for development +pytest==7.4.1 # for development +pytest-textual-snapshot==0.4.0 # for development diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_snapshots.py b/tests/test_snapshots.py new file mode 100644 index 0000000..c4a841f --- /dev/null +++ b/tests/test_snapshots.py @@ -0,0 +1,18 @@ +from pathlib import Path + +import pytest + +# These paths are treated as relative to this file. +APPS_DIR = Path("../src/textual_paint") +PAINT = APPS_DIR / "paint.py" +GALLERY = APPS_DIR / "gallery.py" + +def test_paint_app(snap_compare): + assert snap_compare(PAINT) + +def test_paint_stretch_skew(snap_compare): + assert snap_compare(PAINT, press=["ctrl+w"]) + +def test_gallery_app(snap_compare): + assert snap_compare(GALLERY) +