File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 44
55from _pytest .config import create_terminal_writer
66
7+ # For some reason pytest reports some teardown durations to be 10M - 100M seconds long
8+ # Thus we have this threshold to not take into account the ones which are
9+ # definitely not correct
10+ STORE_DURATIONS_TEARDOWN_THRESHOLD = 60 * 10 # seconds
11+
712
813def pytest_addoption (parser ):
914 group = parser .getgroup (
@@ -80,6 +85,14 @@ def pytest_sessionfinish(session, exitstatus):
8085 for test_reports in terminal_reporter .stats .values ():
8186 for test_report in test_reports :
8287 if hasattr (test_report , "duration" ):
88+ stage = getattr (test_report , "when" , "" )
89+ duration = test_report .duration
90+ if (
91+ stage == "teardown"
92+ and duration > STORE_DURATIONS_TEARDOWN_THRESHOLD
93+ ):
94+ # Ignore not legit teardown durations
95+ continue
8396 durations [test_report .nodeid ] += test_report .duration
8497
8598 with open (report_path , "w" ) as f :
You can’t perform that action at this time.
0 commit comments