Skip to content

Commit b46f4e3

Browse files
committed
try to bring some consistency to terminal-width tests
1 parent 25d1cb8 commit b46f4e3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/test_pytest_icdiff.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import icdiff
2+
from unittest import mock
3+
import pytest
24
import re
35
from pprintpp import pformat
46

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

12+
@pytest.fixture
13+
def with_80_col_terminal():
14+
# haven't found a better way to simulate terminal sizes
15+
# at a lower level yet sadly.
16+
with mock.patch("pytest_icdiff.COLS", 99):
17+
yield
18+
1019

1120
def test_short_dict(testdir):
1221
one = {
@@ -193,6 +202,7 @@ def test_a():
193202
assert drilldown_expression in output
194203

195204

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

209219

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

279290

291+
@pytest.mark.usefixtures("with_80_col_terminal")
280292
def test_really_long_diffs_use_context_mode(testdir):
281293
testdir.makepyfile(
282294
f"""

0 commit comments

Comments
 (0)