Use a separate folder for ANSI art for tests; add more gallery tests

This commit is contained in:
Isaiah Odhner 2024-11-05 07:53:07 -05:00
parent 4387c07e7b
commit dcfb05c58a
5 changed files with 782 additions and 69 deletions

View File

@ -26,7 +26,7 @@ dev_options = parser.add_argument_group('development options')
dev_options.add_argument('--inspect-layout', action='store_true', help='Enables DOM inspector (F12) and middle click highlight')
dev_options.add_argument('--restart-on-changes', action='store_true', help='Restart the app when the source code is changed')
args = parser.parse_args()
args = parser.parse_args(os.environ.get("PYTEST_GALLERY_ARGS", "").split() or None)
def _(text: str) -> str:
"""Placeholder for localization function."""

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
 ▀▀▀ 
  ▀ ▀  
 ▀▀▀ ▀▀▀ 
 ▀_/_▀_______
  / _ ______ 
 _ _ _ _____ 
 _ _▀ ▀_ ▀▀▀ 
 _ ____ ▀__ 
 _/▀ ▀▀ ▀___ 
_/_________ 

View File

@ -0,0 +1,24 @@
===__====_=======___======____=__========____========_==============_)__========
=======_______========▀▄▄ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀=====___(░==========
===____=====__=======   ░░  \ \######/ /  ▀▀=__===)=======____
==_=\=====__===__===   ░░  \###### / # /   =====(░)______====
_//==\\\=_=========   ▀▀▀  ▒ \ ▒ / |   ▒▀▀====((__\=======__
//(O))_\_=====\=__=   ░░  ▒▒▒▒▒▒▒ ▒/▒ / /  ▒▒▀▀====__=♠=)====_____
\\\==//========__==  ░▀▀ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀===\__=(=♠=))=__===__
=_\\/____=====__===  ░░▒▒▓ %\SSSSSSSSSSSSSSSSSSSSSS =======_==(=♠♠♠_)_==___==
==_======____======   ⌂ %\SSSSSSSSSSSSSSSSSSSS =====___=====_♠_)==__\====
========__==__======= _____ %%%%\SSSSSSSSS/%%%%\S ===_=========⌠===_=====__
=======___====_========= /▲▲▲▲▲\_ %%%%%%%%% ⌂⌂⌂  % ==__===_==_♣ ▀ _====__==
=====____====__====   /▲▲ ▲▲\ Ye olde.      ======_=__=  ▌\\=___====
=____==_====__=====    ▲▲▲ Just a fact. ========__==/▌ ▌)))======_
_====__==___==\\===  /  ▲▲ ▲ ▲ ########\  ========__((⌡ ▌////_____=
===__=____====__=== --   ▲▲ ▲▲▲##########\   ======___=== ▌/_=======
=___=__=======__===  =  X  _ - -###\  =======(((( ▌ ))))=====
__=\_=======__========  - _  _ -  ## ======(((    ▌  )))==
=___========_======  / / _ -_  _-  ¡ ¡!¡!  == ===(    ▌   )_
==========__=▀▀▀▀▀▀ ≈≈≈≈≈Θ>   - _- !¡!¡!¡¡!  ░ ==(   ▌ ▌  )
========__== ░░░░░▒  \ \     ░▒ ===(   ▌    )=
======__=== ░▒▒▒▒  ▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▀▀====(((   )))__
===____==== ▒▒▒▒  ▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▀▀======))(((( )))))))= =
___=========   =- @1j01 -=-=-===▀▀===__=====)))))))))))) === 
=============▀ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀====__======_==___________ =

View File

@ -3,6 +3,7 @@
Run with `pytest tests/test_snapshots.py`, or `pytest` to run all tests.
"""
import os
from pathlib import Path, PurePath
from typing import TYPE_CHECKING, Awaitable, Callable, Iterable, Protocol
@ -309,6 +310,27 @@ def test_fill_spiral(snap_compare: SnapCompareType):
assert snap_compare(PAINT, run_before=automate_app, terminal_size=LARGER)
def test_gallery_app(snap_compare: SnapCompareType):
def test_gallery_app_small_art_centered(snap_compare: SnapCompareType):
os.environ["PYTEST_GALLERY_ARGS"] = "./tests/samples_for_gallery_app_tests"
assert snap_compare(GALLERY)
def test_gallery_app_big_art_with_scrollbars(snap_compare: SnapCompareType):
os.environ["PYTEST_GALLERY_ARGS"] = "./tests/samples_for_gallery_app_tests"
assert snap_compare(GALLERY, press=["right"])
def test_gallery_app_nonexistent_folder(snap_compare: SnapCompareType):
os.environ["PYTEST_GALLERY_ARGS"] = "./tests/this_folder_does_not_exist"
# TODO: test app exit with error message
# could spy on `app.exit` or try to listen for an exit event if there is one
# or make a separate test that runs the CLI directly and checks stderr
assert snap_compare(GALLERY, press=["right", "left"]) # arrow keys shouldn't cause errors
def test_gallery_app_empty_folder(snap_compare: SnapCompareType):
os.environ["PYTEST_GALLERY_ARGS"] = "./tests/empty_folder"
# Create the empty folder since Git doesn't track empty folders.
os.makedirs("./tests/empty_folder", exist_ok=True)
assert snap_compare(GALLERY, press=["right", "left"]) # arrow keys shouldn't cause errors
def test_gallery_app_file_path(snap_compare: SnapCompareType):
os.environ["PYTEST_GALLERY_ARGS"] = "./tests/samples_for_gallery_app_tests/scroll_and_candle.ans"
assert snap_compare(GALLERY, press=["right", "left"]) # arrow keys shouldn't cause errors