File tree 5 files changed +63
-1
lines changed
5 files changed +63
-1
lines changed Original file line number Diff line number Diff line change
1
+ Fixed issue where sequences were still being shortened even with ``-vv `` verbosity.
Original file line number Diff line number Diff line change
1
+ New `--force-short-summary ` option to force condensed summary output regardless of verbosity level.
2
+
3
+ This lets users still see condensed summary output of failures for quick reference in log files from job outputs, being especially useful if non-condensed output is very verbose.
Original file line number Diff line number Diff line change 28
28
29
29
from _pytest ._io .saferepr import DEFAULT_REPR_MAX_SIZE
30
30
from _pytest ._io .saferepr import saferepr
31
+ from _pytest ._io .saferepr import saferepr_unlimited
31
32
from _pytest ._version import version
32
33
from _pytest .assertion import util
33
34
from _pytest .config import Config
@@ -433,6 +434,8 @@ def _saferepr(obj: object) -> str:
433
434
return obj .__name__
434
435
435
436
maxsize = _get_maxsize_for_saferepr (util ._config )
437
+ if not maxsize :
438
+ return saferepr_unlimited (obj ).replace ("\n " , "\\ n" )
436
439
return saferepr (obj , maxsize = maxsize ).replace ("\n " , "\\ n" )
437
440
438
441
Original file line number Diff line number Diff line change @@ -161,6 +161,13 @@ def pytest_addoption(parser: Parser) -> None:
161
161
default = True ,
162
162
help = "Do not fold skipped tests in short summary." ,
163
163
)
164
+ group ._addoption (
165
+ "--force-short-summary" ,
166
+ action = "store_true" ,
167
+ dest = "force_short_summary" ,
168
+ default = False ,
169
+ help = "Force condensed summary output regardless of verbosity level." ,
170
+ )
164
171
group ._addoption (
165
172
"-q" ,
166
173
"--quiet" ,
@@ -1500,7 +1507,9 @@ def _get_line_with_reprcrash_message(
1500
1507
except AttributeError :
1501
1508
pass
1502
1509
else :
1503
- if running_on_ci () or config .option .verbose >= 2 :
1510
+ if (
1511
+ running_on_ci () or config .option .verbose >= 2
1512
+ ) and not config .option .force_short_summary :
1504
1513
msg = f" - { msg } "
1505
1514
else :
1506
1515
available_width = tw .fullwidth - line_width
Original file line number Diff line number Diff line change @@ -2617,6 +2617,52 @@ def test():
2617
2617
)
2618
2618
2619
2619
2620
+ def test_full_sequence_print_with_vv (
2621
+ monkeypatch : MonkeyPatch , pytester : Pytester
2622
+ ) -> None :
2623
+ """Do not truncate sequences in summaries with -vv (#11777)."""
2624
+ monkeypatch .setattr (_pytest .terminal , "running_on_ci" , lambda : False )
2625
+
2626
+ pytester .makepyfile (
2627
+ """
2628
+ def test_len_list():
2629
+ l = list(range(10))
2630
+ assert len(l) == 9
2631
+
2632
+ def test_len_dict():
2633
+ d = dict(zip(range(10), range(10)))
2634
+ assert len(d) == 9
2635
+ """
2636
+ )
2637
+
2638
+ result = pytester .runpytest ("-vv" )
2639
+ assert result .ret == 1
2640
+ result .stdout .fnmatch_lines (
2641
+ [
2642
+ "*short test summary info*" ,
2643
+ f"*{ list (range (10 ))} *" ,
2644
+ f"*{ dict (zip (range (10 ), range (10 )))} *" ,
2645
+ ]
2646
+ )
2647
+
2648
+
2649
+ def test_force_short_summary (monkeypatch : MonkeyPatch , pytester : Pytester ) -> None :
2650
+ monkeypatch .setattr (_pytest .terminal , "running_on_ci" , lambda : False )
2651
+
2652
+ pytester .makepyfile (
2653
+ """
2654
+ def test():
2655
+ assert "a\\ n" * 10 == ""
2656
+ """
2657
+ )
2658
+
2659
+ result = pytester .runpytest ("-vv" , "--force-short-summary" )
2660
+ assert result .ret == 1
2661
+ result .stdout .fnmatch_lines (
2662
+ ["*short test summary info*" , "*AssertionError: assert 'a\\ na\\ na\\ na..." ]
2663
+ )
2664
+
2665
+
2620
2666
@pytest .mark .parametrize (
2621
2667
"seconds, expected" ,
2622
2668
[
You can’t perform that action at this time.
0 commit comments