Skip to content

Commit 3bb6f9b

Browse files
committed
Run black
1 parent e817937 commit 3bb6f9b

File tree

2 files changed

+85
-85
lines changed

2 files changed

+85
-85
lines changed

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pytest_plugins = 'pytester'
1+
pytest_plugins = "pytester"

tests/test_pytest_icdiff.py

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import icdiff
2-
from unittest import mock
3-
import pytest
42
import re
53
from pprintpp import pformat
64

7-
YELLOW_ON = '\x1b[1;33m'
8-
COLOR_OFF = '\x1b[m'
9-
GREEN_ON = '\x1b[1;32m'
10-
ANSI_ESCAPE_RE = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]')
11-
5+
YELLOW_ON = "\x1b[1;33m"
6+
COLOR_OFF = "\x1b[m"
7+
GREEN_ON = "\x1b[1;32m"
8+
ANSI_ESCAPE_RE = re.compile(r"(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]")
129

1310

1411
def test_short_dict(testdir):
@@ -19,15 +16,15 @@ def test_short_dict(testdir):
1916
two = {
2017
1: "the number one",
2118
2: "the number three",
22-
6: [1, 2, 3]
19+
6: [1, 2, 3],
2320
}
2421
testdir.makepyfile(
2522
f"""
2623
def test_one():
2724
assert {one!r} == {two!r}
2825
"""
2926
)
30-
output = testdir.runpytest('-vv').stdout.str()
27+
output = testdir.runpytest("-vv").stdout.str()
3128
print(repr(output))
3229
two_left = "'the number two'"
3330
two_right = "'the number three'"
@@ -45,7 +42,7 @@ def test_short_dict_with_colorization(testdir):
4542
two = {
4643
1: "the number one",
4744
2: "the number three",
48-
6: [1, 2, 3]
45+
6: [1, 2, 3],
4946
}
5047
testdir.makepyfile(
5148
f"""
@@ -54,8 +51,8 @@ def test_one():
5451
"""
5552
)
5653
# Force colorization in py TerminalWriter
57-
testdir.monkeypatch.setenv('PY_COLORS', '1')
58-
output = testdir.runpytest('-vv').stdout.str()
54+
testdir.monkeypatch.setenv("PY_COLORS", "1")
55+
output = testdir.runpytest("-vv").stdout.str()
5956
print(repr(output))
6057
two_left = f"'the number t{YELLOW_ON}wo{COLOR_OFF}'"
6158
two_right = f"'the number t{YELLOW_ON}hree{COLOR_OFF}'"
@@ -67,55 +64,55 @@ def test_one():
6764

6865
def test_long_dict(testdir):
6966
one = {
70-
'currency': 'USD',
71-
'default_UK_warehouse': 'xforce',
72-
'default_incoterm': 'EXW',
73-
'name': 'John Doe',
74-
'payment_term': '30% deposit, 70% balance',
75-
'reference': '42551456-a1b3-49bd-beed-b168d9a5ac83',
76-
'website': 'http://megasofas.example.com',
77-
'main_contact': {
78-
'city': 'Madeira',
79-
'country': 'PT',
80-
'email': '[email protected]',
81-
'fax': '012356 789039',
82-
'mobile': '012356 789039',
83-
'name': 'Almeida & Filhos - Example, S.A.',
84-
'phone': '253444802010',
85-
'postcode': '4815-123',
86-
'street': "Senhora Test D'Ajuda, 432",
87-
'street2': 'Moreira de Conegos'
67+
"currency": "USD",
68+
"default_UK_warehouse": "xforce",
69+
"default_incoterm": "EXW",
70+
"name": "John Doe",
71+
"payment_term": "30% deposit, 70% balance",
72+
"reference": "42551456-a1b3-49bd-beed-b168d9a5ac83",
73+
"website": "http://megasofas.example.com",
74+
"main_contact": {
75+
"city": "Madeira",
76+
"country": "PT",
77+
"email": "[email protected]",
78+
"fax": "012356 789039",
79+
"mobile": "012356 789039",
80+
"name": "Almeida & Filhos - Example, S.A.",
81+
"phone": "253444802010",
82+
"postcode": "4815-123",
83+
"street": "Senhora Test D'Ajuda, 432",
84+
"street2": "Moreira de Conegos",
8885
},
8986
}
9087
two = {
91-
'currency': 'USD',
92-
'default_UK_warehouse': 'iforce',
93-
'default_incoterm': 'EXW',
94-
'freight_forwarder': 'flexport',
95-
'name': 'John Doe',
96-
'payment_term': '30% deposit, 70% balance',
97-
'reference': '42551456-a1b3-49bd-beed-b168d9a5ac83',
98-
'website': 'http://megasofas.example.com',
99-
'main_contact': {
100-
'name': 'Almeida & Filhos - Example, S.A.',
101-
'email': '[email protected]',
102-
'street': "Senhora Test D'Ajuda, 432",
103-
'street2': 'Moreira de Conegos',
104-
'postcode': '4815-123',
105-
'city': 'Madeira',
106-
'country': 'PT',
107-
'phone': '253444802010',
108-
'fax': '012356 789039',
109-
'mobile': '012356 789039'
110-
}
88+
"currency": "USD",
89+
"default_UK_warehouse": "iforce",
90+
"default_incoterm": "EXW",
91+
"freight_forwarder": "flexport",
92+
"name": "John Doe",
93+
"payment_term": "30% deposit, 70% balance",
94+
"reference": "42551456-a1b3-49bd-beed-b168d9a5ac83",
95+
"website": "http://megasofas.example.com",
96+
"main_contact": {
97+
"name": "Almeida & Filhos - Example, S.A.",
98+
"email": "[email protected]",
99+
"street": "Senhora Test D'Ajuda, 432",
100+
"street2": "Moreira de Conegos",
101+
"postcode": "4815-123",
102+
"city": "Madeira",
103+
"country": "PT",
104+
"phone": "253444802010",
105+
"fax": "012356 789039",
106+
"mobile": "012356 789039",
107+
},
111108
}
112109
testdir.makepyfile(
113110
f"""
114111
def test_two():
115112
assert {one!r} == {two!r}
116113
"""
117114
)
118-
output = testdir.runpytest('-vv', '--color=yes').stdout.str()
115+
output = testdir.runpytest("-vv", "--color=yes").stdout.str()
119116
expected_l = f"'default_UK_warehouse': '{YELLOW_ON}x{COLOR_OFF}force'"
120117
expected_r = f"'default_UK_warehouse': '{YELLOW_ON}i{COLOR_OFF}force'"
121118
expected_missing = f"{GREEN_ON} 'freight_forwarder': 'flexport',{COLOR_OFF}"
@@ -126,7 +123,7 @@ def test_two():
126123

127124
def test_only_works_for_equals(testdir):
128125
testdir.makepyfile(
129-
f"""
126+
"""
130127
def test_in():
131128
assert 1 in [2, 3, 4]
132129
@@ -145,29 +142,31 @@ def _assert_line_in_ignoring_whitespace(expected, block):
145142
for line in block.splitlines():
146143
if all(part in line for part in parts):
147144
return True
148-
assert False, f'could not find {expected} in:\n{block}'
145+
assert False, f"could not find {expected} in:\n{block}"
149146

150147

151148
def test_prepends_icdiff_output_lines_with_color_off(testdir):
152-
one = ['hello', 'hello']
153-
two = ['bello', 'hella']
149+
one = ["hello", "hello"]
150+
two = ["bello", "hella"]
154151
testdir.makepyfile(
155152
f"""
156153
def test_thing():
157154
assert {one!r} == {two!r}
158155
"""
159156
)
160-
output = testdir.runpytest('--color=yes').stdout.str()
161-
expected = list(icdiff.ConsoleDiff().make_table(
162-
pformat(one, width=1).splitlines(),
163-
pformat(two, width=1).splitlines(),
164-
))
165-
print('\n'.join(repr(l) for l in output.splitlines()))
157+
output = testdir.runpytest("--color=yes").stdout.str()
158+
expected = list(
159+
icdiff.ConsoleDiff().make_table(
160+
pformat(one, width=1).splitlines(),
161+
pformat(two, width=1).splitlines(),
162+
)
163+
)
164+
print("\n".join(repr(l) for l in output.splitlines()))
166165
_assert_line_in_ignoring_whitespace(expected[0], output)
167166

168167

169168
def strip_color_codes(s):
170-
return re.sub(r'\x1b\[[0-9;]*m', '', s)
169+
return re.sub(r"\x1b\[[0-9;]*m", "", s)
171170

172171

173172
def test_avoids_single_line_diffs(testdir):
@@ -179,7 +178,7 @@ def test_one():
179178
assert {one!r} == {two!r}
180179
"""
181180
)
182-
output = testdir.runpytest('-vv').stdout.str()
181+
output = testdir.runpytest("-vv").stdout.str()
183182
print(repr(output))
184183
assert "1: '1', 1: '1'," in strip_color_codes(output)
185184

@@ -192,22 +191,24 @@ def test_a():
192191
"""
193192
)
194193
output = testdir.runpytest().stdout.str()
195-
drilldown_expression = 'where 3 = len([1, 2, 3])'
194+
drilldown_expression = "where 3 = len([1, 2, 3])"
196195
assert drilldown_expression in output
197196

198197

199198
def test_long_lines_in_comparators_are_wrapped_sensibly_multiline(testdir):
200-
left = {1: "hello " * 20, 2: 'two'}
201-
right = {1: "hella " * 20, 2: 'two'}
199+
left = {1: "hello " * 20, 2: "two"}
200+
right = {1: "hella " * 20, 2: "two"}
202201
testdir.makepyfile(
203202
f"""
204203
def test_one():
205204
assert {left!r} == {right!r}
206205
"""
207206
)
208-
output = testdir.runpytest('-vv', '--color=yes').stdout.str()
209-
comparison_line = next(l for l in output.splitlines() if '1:' in l and "assert" not in l)
210-
assert comparison_line.count('hell') < 13
207+
output = testdir.runpytest("-vv", "--color=yes").stdout.str()
208+
comparison_line = next(
209+
l for l in output.splitlines() if "1:" in l and "assert" not in l
210+
)
211+
assert comparison_line.count("hell") < 13
211212

212213

213214
def test_long_lines_in_comparators_are_wrapped_sensibly_singleline(testdir):
@@ -219,12 +220,11 @@ def test_one():
219220
assert {left!r} == {right!r}
220221
"""
221222
)
222-
output = testdir.runpytest('-vv', '--color=yes').stdout.str()
223+
output = testdir.runpytest("-vv", "--color=yes").stdout.str()
223224
comparison_line = next(
224-
l for l in output.splitlines()
225-
if "hell" in l and "assert" not in l
225+
l for l in output.splitlines() if "hell" in l and "assert" not in l
226226
)
227-
assert comparison_line.count('hell') < 15
227+
assert comparison_line.count("hell") < 15
228228

229229

230230
def test_columns_are_calculated_outside_hook(testdir):
@@ -245,50 +245,50 @@ def test_one():
245245
assert {left!r} == {right!r}
246246
"""
247247
)
248-
testdir.monkeypatch.setenv('COLUMNS', '50')
248+
testdir.monkeypatch.setenv("COLUMNS", "50")
249249
# testdir._method = 'subprocess'
250250
output = testdir.runpytest(
251-
'-vv', '--color=yes',
251+
"-vv",
252+
"--color=yes",
252253
).stdout.str()
253254
comparison_line = next(
254-
l for l in output.splitlines()
255-
if 'hell' in l and "assert" not in l
255+
l for l in output.splitlines() if "hell" in l and "assert" not in l
256256
)
257-
assert comparison_line.count('hell') > 5
257+
assert comparison_line.count("hell") > 5
258258

259259

260260
def test_small_numbers_are_specialcased(testdir):
261261
testdir.makepyfile(
262-
f"""
262+
"""
263263
def test_one():
264264
assert 404 == 400
265265
"""
266266
)
267-
output = testdir.runpytest('-vv', '--color=yes').stdout.str()
267+
output = testdir.runpytest("-vv", "--color=yes").stdout.str()
268268
assert "assert 404 == 400" in output
269269
assert "E assert 404 == 400" in output
270270

271271

272272
def test_larger_numbers_are_sane(testdir):
273273
testdir.makepyfile(
274-
f"""
274+
"""
275275
def test_one():
276276
assert 123456 == 1234567
277277
"""
278278
)
279-
output = testdir.runpytest('-vv', '--color=yes').stdout.str()
279+
output = testdir.runpytest("-vv", "--color=yes").stdout.str()
280280
assert f"123456 123456{GREEN_ON}7" in output
281281

282282

283283
def test_really_long_diffs_use_context_mode(testdir):
284284
testdir.makepyfile(
285-
f"""
285+
"""
286286
def test_one():
287287
one = list(range(100))
288288
two = list(range(20)) + ["X"] + list(range(20, 50)) + ["Y"] + list(range(53, 100))
289289
assert one == two
290290
"""
291291
)
292-
output = testdir.runpytest('-vv', '--color=yes', '-r=no').stdout.str()
292+
output = testdir.runpytest("-vv", "--color=yes", "-r=no").stdout.str()
293293
assert len(output.splitlines()) < 50
294294
assert "---" in output # context split marker

0 commit comments

Comments
 (0)