Skip to content

Commit

Permalink
try to bring some consistency to terminal-width tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hjwp committed Aug 30, 2023
1 parent 25d1cb8 commit b46f4e3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_pytest_icdiff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import icdiff
from unittest import mock
import pytest
import re
from pprintpp import pformat

Expand All @@ -7,6 +9,13 @@
GREEN_ON = '\x1b[1;32m'
ANSI_ESCAPE_RE = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]')

@pytest.fixture
def with_80_col_terminal():
# haven't found a better way to simulate terminal sizes
# at a lower level yet sadly.
with mock.patch("pytest_icdiff.COLS", 99):
yield


def test_short_dict(testdir):
one = {
Expand Down Expand Up @@ -193,6 +202,7 @@ def test_a():
assert drilldown_expression in output


@pytest.mark.usefixtures("with_80_col_terminal")
def test_long_lines_in_comparators_are_wrapped_sensibly_multiline(testdir):
left = {1: "hello " * 20, 2: 'two'}
right = {1: "hella " * 20, 2: 'two'}
Expand All @@ -207,6 +217,7 @@ def test_one():
assert comparison_line.count('hell') < 13


@pytest.mark.usefixtures("with_80_col_terminal")
def test_long_lines_in_comparators_are_wrapped_sensibly_singleline(testdir):
left = "hello " * 10
right = "hella " * 10
Expand Down Expand Up @@ -277,6 +288,7 @@ def test_one():
assert f"123456 123456{GREEN_ON}7" in output


@pytest.mark.usefixtures("with_80_col_terminal")
def test_really_long_diffs_use_context_mode(testdir):
testdir.makepyfile(
f"""
Expand Down

0 comments on commit b46f4e3

Please sign in to comment.