@@ -1532,6 +1532,15 @@ def test_render_runs_the_app(self):
15321532
15331533@pytest .fixture
15341534def compare (monkeypatch , tmp_path , snap_compare ):
1535+ # The snapshots we've generated using current versions of Textual aren't
1536+ # expected to match anymore on Python 3.7, as Textual dropped support for
1537+ # Python 3.7 in the 0.44 release. However, we'd still like to run our
1538+ # snapshot tests on Python 3.7, to confirm that no unexpected exceptions
1539+ # occur and that the app doesn't crash. So, allow `snap_compare()` to drive
1540+ # the application, but always return `True` on Python 3.7 as long as no
1541+ # exception was raised.
1542+ succeed_even_if_mismatched = sys .version_info < (3 , 8 )
1543+
15351544 def compare_impl (
15361545 allocations : Iterator [AllocationRecord ],
15371546 press : Iterable [str ] = (),
@@ -1550,21 +1559,20 @@ def compare_impl(
15501559 with monkeypatch .context () as app_patch :
15511560 app_patch .setitem (globals (), app_global , app )
15521561 tmp_main .write_text (f"from { __name__ } import { app_global } as app" )
1553- return snap_compare (
1554- str (tmp_main ),
1555- press = press ,
1556- terminal_size = terminal_size ,
1557- run_before = run_before ,
1562+ return (
1563+ snap_compare (
1564+ str (tmp_main ),
1565+ press = press ,
1566+ terminal_size = terminal_size ,
1567+ run_before = run_before ,
1568+ )
1569+ or succeed_even_if_mismatched
15581570 )
15591571
15601572 yield compare_impl
15611573
15621574
15631575class TestTUILooks :
1564- @pytest .mark .skipif (
1565- sys .version_info < (3 , 8 ),
1566- reason = "This test requires Textual 0.49 or higher, which doesn't support 3.7" ,
1567- )
15681576 def test_basic (self , compare ):
15691577 # GIVEN
15701578 code = dedent (
@@ -1599,10 +1607,6 @@ def generate_primes():
15991607 getlines .return_value = code .splitlines ()
16001608 assert compare (peak_allocations , press = [])
16011609
1602- @pytest .mark .skipif (
1603- sys .version_info < (3 , 8 ),
1604- reason = "This test requires Textual 0.48 or higher, which doesn't support 3.7" ,
1605- )
16061610 def test_basic_node_selected_not_leaf (self , compare ):
16071611 # GIVEN
16081612 code = dedent (
@@ -1637,10 +1641,6 @@ def generate_primes():
16371641 getlines .return_value = code .splitlines ()
16381642 assert compare (peak_allocations , press = [* ["down" ] * 2 ])
16391643
1640- @pytest .mark .skipif (
1641- sys .version_info < (3 , 8 ),
1642- reason = "This test requires Textual 0.49 or higher, which doesn't support 3.7" ,
1643- )
16441644 def test_basic_node_selected_leaf (self , compare ):
16451645 # GIVEN
16461646 code = dedent (
@@ -1675,10 +1675,6 @@ def generate_primes():
16751675 getlines .return_value = code .splitlines ()
16761676 assert compare (peak_allocations , press = [* ["down" ] * 3 ])
16771677
1678- @pytest .mark .skipif (
1679- sys .version_info < (3 , 8 ),
1680- reason = "This test requires Textual 0.49 or higher, which doesn't support 3.7" ,
1681- )
16821678 def test_two_chains (self , compare ):
16831679 # GIVEN
16841680 code = dedent (
@@ -1726,10 +1722,6 @@ def generate_primes():
17261722 getlines .return_value = code .splitlines ()
17271723 assert compare (peak_allocations , press = [])
17281724
1729- @pytest .mark .skipif (
1730- sys .version_info < (3 , 8 ),
1731- reason = "This test requires Textual 0.48 or higher, which doesn't support 3.7" ,
1732- )
17331725 def test_two_chains_after_expanding_second (self , compare ):
17341726 # GIVEN
17351727 code = dedent (
@@ -1779,10 +1771,6 @@ def generate_primes():
17791771 getlines .return_value = code .splitlines ()
17801772 assert compare (peak_allocations , press = [* ["down" ] * 4 , "e" ])
17811773
1782- @pytest .mark .skipif (
1783- sys .version_info < (3 , 8 ),
1784- reason = "This test requires Textual 0.49 or higher, which doesn't support 3.7" ,
1785- )
17861774 def test_hide_import_system (self , compare ):
17871775 # GIVEN
17881776 code = dedent (
@@ -1833,10 +1821,6 @@ def generate_primes():
18331821 getlines .return_value = code .splitlines ()
18341822 assert compare (peak_allocations , press = ["i" ])
18351823
1836- @pytest .mark .skipif (
1837- sys .version_info < (3 , 8 ),
1838- reason = "This test requires Textual 0.49 or higher, which doesn't support 3.7" ,
1839- )
18401824 def test_show_uninteresting (self , compare ):
18411825 # GIVEN
18421826 code = dedent (
@@ -1887,10 +1871,6 @@ def generate_primes():
18871871 getlines .return_value = code .splitlines ()
18881872 assert compare (peak_allocations , press = ["u" ])
18891873
1890- @pytest .mark .skipif (
1891- sys .version_info < (3 , 8 ),
1892- reason = "This test requires Textual 0.49 or higher, which doesn't support 3.7" ,
1893- )
18941874 def test_show_uninteresting_and_hide_import_system (self , compare ):
18951875 # GIVEN
18961876 code = dedent (
@@ -1942,10 +1922,6 @@ def generate_primes():
19421922 getlines .return_value = code .splitlines ()
19431923 assert compare (peak_allocations , press = ["u" , "i" ])
19441924
1945- @pytest .mark .skipif (
1946- sys .version_info < (3 , 8 ),
1947- reason = "This test requires Textual 0.48 or higher, which doesn't support 3.7" ,
1948- )
19491925 def test_select_screen (self , tmp_path , compare ):
19501926 # GIVEN
19511927 code = dedent (
@@ -1979,10 +1955,6 @@ def generate_primes():
19791955 getlines .return_value = code .splitlines ()
19801956 assert compare (peak_allocations , press = [* ["down" ] * 3 ])
19811957
1982- @pytest .mark .skipif (
1983- sys .version_info < (3 , 8 ),
1984- reason = "This test requires Textual 0.49 or higher, which doesn't support 3.7" ,
1985- )
19861958 def test_allocations_of_different_sizes (self , compare ):
19871959 # GIVEN
19881960 peak_allocations = [
@@ -2003,10 +1975,6 @@ def test_allocations_of_different_sizes(self, compare):
20031975 getlines .return_value = []
20041976 assert compare (peak_allocations , press = [], terminal_size = (350 , 100 ))
20051977
2006- @pytest .mark .skipif (
2007- sys .version_info < (3 , 8 ),
2008- reason = "This test requires Textual 0.49 or higher, which doesn't support 3.7" ,
2009- )
20101978 def test_biggest_allocations (self , compare ):
20111979 # GIVEN
20121980 peak_allocations = [
0 commit comments