File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change
1
+ New ``--durations-min `` command-line flag controls the minimal duration for inclusion in the slowest list of tests shown by ``--durations ``. Previously this was hard-coded to ``0.005s ``.
Original file line number Diff line number Diff line change @@ -426,14 +426,15 @@ Pytest supports the use of ``breakpoint()`` with the following behaviours:
426
426
Profiling test execution duration
427
427
-------------------------------------
428
428
429
+ .. versionchanged :: 6.0
429
430
430
- To get a list of the slowest 10 test durations:
431
+ To get a list of the slowest 10 test durations over 1.0s long :
431
432
432
433
.. code-block :: bash
433
434
434
- pytest --durations=10
435
+ pytest --durations=10 --durations-min=1.0
435
436
436
- By default, pytest will not show test durations that are too small (<0.01s ) unless ``-vv `` is passed on the command-line.
437
+ By default, pytest will not show test durations that are too small (<0.005s ) unless ``-vv `` is passed on the command-line.
437
438
438
439
439
440
.. _faulthandler :
Original file line number Diff line number Diff line change @@ -52,10 +52,19 @@ def pytest_addoption(parser: Parser) -> None:
52
52
metavar = "N" ,
53
53
help = "show N slowest setup/test durations (N=0 for all)." ,
54
54
)
55
+ group .addoption (
56
+ "--durations-min" ,
57
+ action = "store" ,
58
+ type = float ,
59
+ default = 0.005 ,
60
+ metavar = "N" ,
61
+ help = "Minimal duration in seconds for inclusion in slowest list. Default 0.005" ,
62
+ )
55
63
56
64
57
65
def pytest_terminal_summary (terminalreporter : "TerminalReporter" ) -> None :
58
66
durations = terminalreporter .config .option .durations
67
+ durations_min = terminalreporter .config .option .durations_min
59
68
verbose = terminalreporter .config .getvalue ("verbose" )
60
69
if durations is None :
61
70
return
@@ -76,11 +85,11 @@ def pytest_terminal_summary(terminalreporter: "TerminalReporter") -> None:
76
85
dlist = dlist [:durations ]
77
86
78
87
for i , rep in enumerate (dlist ):
79
- if verbose < 2 and rep .duration < 0.005 :
88
+ if verbose < 2 and rep .duration < durations_min :
80
89
tr .write_line ("" )
81
90
tr .write_line (
82
- "(%s durations < 0.005s hidden. Use -vv to show these durations.)"
83
- % (len (dlist ) - i )
91
+ "(%s durations < %gs hidden. Use -vv to show these durations.)"
92
+ % (len (dlist ) - i , durations_min )
84
93
)
85
94
break
86
95
tr .write_line ("{:02.2f}s {:<8} {}" .format (rep .duration , rep .when , rep .nodeid ))
You can’t perform that action at this time.
0 commit comments