Skip to content

Commit f99a6c9

Browse files
committed
tests: Ignore Textual snapshot mismatches on 3.7
The snapshots we've generated using current versions of Textual aren't expected to match anymore on Python 3.7, as Textual dropped support for Python 3.7 in the 0.44 release. However, we'd still like to run our snapshot tests on Python 3.7, to confirm that no unexpected exceptions occur and that the app doesn't crash. So, force `--snapshot-update` to always be used on old versions of Python, ensuring that the tests run but mismatching snapshots are not errors (and instead generate new snapshot files which we'll ignore). Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
1 parent 9b54ea4 commit f99a6c9

File tree

2 files changed

+9
-50
lines changed

2 files changed

+9
-50
lines changed

tests/conftest.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ def free_port():
1414

1515

1616
def pytest_configure(config):
17-
# Several of the tree reporter tests require Textual 0.48, which does not
18-
# support Python 3.7, but skipping those tests causes the test suite to
19-
# fail due to unused snapshots. Override the configuration for Python 3.7
20-
# so that unused snapshots are a warning, not an error.
17+
# The snapshots we've generated using current versions of Textual aren't
18+
# expected to match anymore on Python 3.7, as Textual dropped support for
19+
# Python 3.7 in the 0.44 release. However, we'd still like to run our
20+
# snapshot tests on Python 3.7, to confirm that no unexpected exceptions
21+
# occur and that the app doesn't crash. So, force `--snapshot-update`
22+
# to always be used on old versions of Python, ensuring that the tests run
23+
# but mismatching snapshots are not errors (and instead generate new
24+
# snapshot files which we'll ignore).
2125
if sys.version_info < (3, 8):
22-
config.option.warn_unused_snapshots = True
26+
config.option.update_snapshots = True

tests/unit/test_tree_reporter.py

-45
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from dataclasses import dataclass
32
from textwrap import dedent
43
from typing import Any
@@ -1561,10 +1560,6 @@ def compare_impl(
15611560

15621561

15631562
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-
)
15681563
def test_basic(self, compare):
15691564
# GIVEN
15701565
code = dedent(
@@ -1599,10 +1594,6 @@ def generate_primes():
15991594
getlines.return_value = code.splitlines()
16001595
assert compare(peak_allocations, press=[])
16011596

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-
)
16061597
def test_basic_node_selected_not_leaf(self, compare):
16071598
# GIVEN
16081599
code = dedent(
@@ -1637,10 +1628,6 @@ def generate_primes():
16371628
getlines.return_value = code.splitlines()
16381629
assert compare(peak_allocations, press=[*["down"] * 2])
16391630

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-
)
16441631
def test_basic_node_selected_leaf(self, compare):
16451632
# GIVEN
16461633
code = dedent(
@@ -1675,10 +1662,6 @@ def generate_primes():
16751662
getlines.return_value = code.splitlines()
16761663
assert compare(peak_allocations, press=[*["down"] * 3])
16771664

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-
)
16821665
def test_two_chains(self, compare):
16831666
# GIVEN
16841667
code = dedent(
@@ -1726,10 +1709,6 @@ def generate_primes():
17261709
getlines.return_value = code.splitlines()
17271710
assert compare(peak_allocations, press=[])
17281711

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-
)
17331712
def test_two_chains_after_expanding_second(self, compare):
17341713
# GIVEN
17351714
code = dedent(
@@ -1779,10 +1758,6 @@ def generate_primes():
17791758
getlines.return_value = code.splitlines()
17801759
assert compare(peak_allocations, press=[*["down"] * 4, "e"])
17811760

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-
)
17861761
def test_hide_import_system(self, compare):
17871762
# GIVEN
17881763
code = dedent(
@@ -1833,10 +1808,6 @@ def generate_primes():
18331808
getlines.return_value = code.splitlines()
18341809
assert compare(peak_allocations, press=["i"])
18351810

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-
)
18401811
def test_show_uninteresting(self, compare):
18411812
# GIVEN
18421813
code = dedent(
@@ -1887,10 +1858,6 @@ def generate_primes():
18871858
getlines.return_value = code.splitlines()
18881859
assert compare(peak_allocations, press=["u"])
18891860

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-
)
18941861
def test_show_uninteresting_and_hide_import_system(self, compare):
18951862
# GIVEN
18961863
code = dedent(
@@ -1942,10 +1909,6 @@ def generate_primes():
19421909
getlines.return_value = code.splitlines()
19431910
assert compare(peak_allocations, press=["u", "i"])
19441911

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-
)
19491912
def test_select_screen(self, tmp_path, compare):
19501913
# GIVEN
19511914
code = dedent(
@@ -1979,10 +1942,6 @@ def generate_primes():
19791942
getlines.return_value = code.splitlines()
19801943
assert compare(peak_allocations, press=[*["down"] * 3])
19811944

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-
)
19861945
def test_allocations_of_different_sizes(self, compare):
19871946
# GIVEN
19881947
peak_allocations = [
@@ -2003,10 +1962,6 @@ def test_allocations_of_different_sizes(self, compare):
20031962
getlines.return_value = []
20041963
assert compare(peak_allocations, press=[], terminal_size=(350, 100))
20051964

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-
)
20101965
def test_biggest_allocations(self, compare):
20111966
# GIVEN
20121967
peak_allocations = [

0 commit comments

Comments
 (0)