@@ -1532,6 +1532,15 @@ def test_render_runs_the_app(self):
1532
1532
1533
1533
@pytest .fixture
1534
1534
def 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
+
1535
1544
def compare_impl (
1536
1545
allocations : Iterator [AllocationRecord ],
1537
1546
press : Iterable [str ] = (),
@@ -1550,21 +1559,20 @@ def compare_impl(
1550
1559
with monkeypatch .context () as app_patch :
1551
1560
app_patch .setitem (globals (), app_global , app )
1552
1561
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
1558
1570
)
1559
1571
1560
1572
yield compare_impl
1561
1573
1562
1574
1563
1575
class 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
- )
1568
1576
def test_basic (self , compare ):
1569
1577
# GIVEN
1570
1578
code = dedent (
@@ -1599,10 +1607,6 @@ def generate_primes():
1599
1607
getlines .return_value = code .splitlines ()
1600
1608
assert compare (peak_allocations , press = [])
1601
1609
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
- )
1606
1610
def test_basic_node_selected_not_leaf (self , compare ):
1607
1611
# GIVEN
1608
1612
code = dedent (
@@ -1637,10 +1641,6 @@ def generate_primes():
1637
1641
getlines .return_value = code .splitlines ()
1638
1642
assert compare (peak_allocations , press = [* ["down" ] * 2 ])
1639
1643
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
- )
1644
1644
def test_basic_node_selected_leaf (self , compare ):
1645
1645
# GIVEN
1646
1646
code = dedent (
@@ -1675,10 +1675,6 @@ def generate_primes():
1675
1675
getlines .return_value = code .splitlines ()
1676
1676
assert compare (peak_allocations , press = [* ["down" ] * 3 ])
1677
1677
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
- )
1682
1678
def test_two_chains (self , compare ):
1683
1679
# GIVEN
1684
1680
code = dedent (
@@ -1726,10 +1722,6 @@ def generate_primes():
1726
1722
getlines .return_value = code .splitlines ()
1727
1723
assert compare (peak_allocations , press = [])
1728
1724
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
- )
1733
1725
def test_two_chains_after_expanding_second (self , compare ):
1734
1726
# GIVEN
1735
1727
code = dedent (
@@ -1779,10 +1771,6 @@ def generate_primes():
1779
1771
getlines .return_value = code .splitlines ()
1780
1772
assert compare (peak_allocations , press = [* ["down" ] * 4 , "e" ])
1781
1773
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
- )
1786
1774
def test_hide_import_system (self , compare ):
1787
1775
# GIVEN
1788
1776
code = dedent (
@@ -1833,10 +1821,6 @@ def generate_primes():
1833
1821
getlines .return_value = code .splitlines ()
1834
1822
assert compare (peak_allocations , press = ["i" ])
1835
1823
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
- )
1840
1824
def test_show_uninteresting (self , compare ):
1841
1825
# GIVEN
1842
1826
code = dedent (
@@ -1887,10 +1871,6 @@ def generate_primes():
1887
1871
getlines .return_value = code .splitlines ()
1888
1872
assert compare (peak_allocations , press = ["u" ])
1889
1873
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
- )
1894
1874
def test_show_uninteresting_and_hide_import_system (self , compare ):
1895
1875
# GIVEN
1896
1876
code = dedent (
@@ -1942,10 +1922,6 @@ def generate_primes():
1942
1922
getlines .return_value = code .splitlines ()
1943
1923
assert compare (peak_allocations , press = ["u" , "i" ])
1944
1924
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
- )
1949
1925
def test_select_screen (self , tmp_path , compare ):
1950
1926
# GIVEN
1951
1927
code = dedent (
@@ -1979,10 +1955,6 @@ def generate_primes():
1979
1955
getlines .return_value = code .splitlines ()
1980
1956
assert compare (peak_allocations , press = [* ["down" ] * 3 ])
1981
1957
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
- )
1986
1958
def test_allocations_of_different_sizes (self , compare ):
1987
1959
# GIVEN
1988
1960
peak_allocations = [
@@ -2003,10 +1975,6 @@ def test_allocations_of_different_sizes(self, compare):
2003
1975
getlines .return_value = []
2004
1976
assert compare (peak_allocations , press = [], terminal_size = (350 , 100 ))
2005
1977
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
- )
2010
1978
def test_biggest_allocations (self , compare ):
2011
1979
# GIVEN
2012
1980
peak_allocations = [
0 commit comments