Skip to content

Commit

Permalink
tests: Skip some snapshot tests on Python 3.7
Browse files Browse the repository at this point in the history
The latest versions of Textual only support Python 3.8 and higher, so
differences from the snapshot are expected when running Python 3.7.

Signed-off-by: Matt Wozniski <[email protected]>
  • Loading branch information
godlygeek committed Feb 5, 2024
1 parent 94e5154 commit 1fae231
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import socket
import sys

import pytest

Expand All @@ -10,3 +11,12 @@ def free_port():
port_number = s.getsockname()[1]
s.close()
return port_number


def pytest_configure(config):
# Several of the tree reporter tests require Textual 0.48, which does not
# support Python 3.7, but skipping those tests causes the test suite to
# fail due to unused snapshots. Override the configuration for Python 3.7
# so that unused snapshots are a warning, not an error.
if sys.version_info < (3, 8):
config.option.warn_unused_snapshots = True
13 changes: 13 additions & 0 deletions tests/unit/test_tree_reporter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from dataclasses import dataclass
from textwrap import dedent
from typing import Any
Expand Down Expand Up @@ -1594,6 +1595,10 @@ def generate_primes():
getlines.return_value = code.splitlines()
assert compare(peak_allocations, press=[])

@pytest.mark.skipif(
sys.version_info < (3, 8),
reason="This test requires Textual 0.48 or higher, which doesn't support 3.7",
)
def test_basic_node_selected_not_leaf(self, compare):
# GIVEN
code = dedent(
Expand Down Expand Up @@ -1709,6 +1714,10 @@ def generate_primes():
getlines.return_value = code.splitlines()
assert compare(peak_allocations, press=[])

@pytest.mark.skipif(
sys.version_info < (3, 8),
reason="This test requires Textual 0.48 or higher, which doesn't support 3.7",
)
def test_two_chains_after_expanding_second(self, compare):
# GIVEN
code = dedent(
Expand Down Expand Up @@ -1909,6 +1918,10 @@ def generate_primes():
getlines.return_value = code.splitlines()
assert compare(peak_allocations, press=["u", "i"])

@pytest.mark.skipif(
sys.version_info < (3, 8),
reason="This test requires Textual 0.48 or higher, which doesn't support 3.7",
)
def test_select_screen(self, tmp_path, compare):
# GIVEN
code = dedent(
Expand Down

0 comments on commit 1fae231

Please sign in to comment.