@@ -24,7 +24,7 @@ def test_one():
24
24
assert { one !r} == { two !r}
25
25
"""
26
26
)
27
- output = testdir .runpytest ().stdout .str ()
27
+ output = testdir .runpytest ('-vv' ).stdout .str ()
28
28
print (repr (output ))
29
29
two_left = "'the number two'"
30
30
two_right = "'the number three'"
@@ -52,7 +52,7 @@ def test_one():
52
52
)
53
53
# Force colorization in py TerminalWriter
54
54
testdir .monkeypatch .setenv ('PY_COLORS' , '1' )
55
- output = testdir .runpytest ().stdout .str ()
55
+ output = testdir .runpytest ('-vv' ).stdout .str ()
56
56
print (repr (output ))
57
57
two_left = f"'the number t{ YELLOW_ON } wo{ COLOR_OFF } '"
58
58
two_right = f"'the number t{ YELLOW_ON } hree{ COLOR_OFF } '"
@@ -173,7 +173,7 @@ def test_one():
173
173
assert { one !r} == { two !r}
174
174
"""
175
175
)
176
- output = testdir .runpytest ().stdout .str ()
176
+ output = testdir .runpytest ('-vv' ).stdout .str ()
177
177
print (repr (output ))
178
178
assert re .search (r"1: '1',\s+$" , output , flags = re .MULTILINE )
179
179
@@ -188,3 +188,64 @@ def test_a():
188
188
output = testdir .runpytest ().stdout .str ()
189
189
drilldown_expression = 'where 3 = len([1, 2, 3])'
190
190
assert drilldown_expression in output
191
+
192
+
193
+ def test_long_lines_in_comparators_are_wrapped_sensibly_multiline (testdir ):
194
+ left = {1 : "hello " * 20 , 2 : 'two' }
195
+ right = {1 : "hella " * 20 , 2 : 'two' }
196
+ testdir .makepyfile (
197
+ f"""
198
+ def test_one():
199
+ assert { left !r} == { right !r}
200
+ """
201
+ )
202
+ output = testdir .runpytest ('-vv' , '--color=yes' ).stdout .str ()
203
+ comparison_line = next (l for l in output .splitlines () if '1:' in l and "assert" not in l )
204
+ assert comparison_line .count ('hell' ) < 13
205
+
206
+ def test_long_lines_in_comparators_are_wrapped_sensibly_singleline (testdir ):
207
+ left = "hello " * 10
208
+ right = "hella " * 10
209
+ testdir .makepyfile (
210
+ f"""
211
+ def test_one():
212
+ assert { left !r} == { right !r}
213
+ """
214
+ )
215
+ output = testdir .runpytest ('-vv' , '--color=yes' ).stdout .str ()
216
+ comparison_line = next (
217
+ l for l in output .splitlines ()
218
+ if "hell" in l and "assert" not in l
219
+ )
220
+ assert comparison_line .count ('hell' ) < 15
221
+
222
+
223
+ def test_columns_are_calculated_outside_hook (testdir ):
224
+ """
225
+ ok for some reason if you get the TerminalWriter width
226
+ inside of the hook it just always returns 80.
227
+ but (bear with me here) if you monkeypatch.setenv(COLUMNS)
228
+ then it _does_ affect the width inside the hook
229
+ (which is where we don't want to measure it)
230
+ but it does _not_ affect the one outside the hook
231
+ (which is the one we want to use).
232
+ """
233
+ left = "hello " * 10
234
+ right = "hella " * 10
235
+ testdir .makepyfile (
236
+ f"""
237
+ def test_one():
238
+ assert { left !r} == { right !r}
239
+ """
240
+ )
241
+ testdir .monkeypatch .setenv ('COLUMNS' , '50' )
242
+ # testdir._method = 'subprocess'
243
+ output = testdir .runpytest (
244
+ '-vv' , '--color=yes' ,
245
+ ).stdout .str ()
246
+ comparison_line = next (
247
+ l for l in output .splitlines ()
248
+ if 'hell' in l and "assert" not in l
249
+ )
250
+ assert comparison_line .count ('hell' ) > 5
251
+
0 commit comments