Skip to content

Commit 512a0e5

Browse files
Merge pull request #429 from CyberiaResurrection/AdjustTestTiming
Adjust duration_by_test definition to reflect new use
2 parents 37eb0c3 + b7552f5 commit 512a0e5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

mutmut/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
__version__ = '3.3.1'
44

55

6-
duration_by_test = {}
6+
duration_by_test = defaultdict(float)
77
stats_time = None
88
config = None
99

@@ -14,7 +14,7 @@
1414
def _reset_globals():
1515
global duration_by_test, stats_time, config, _stats, tests_by_mangled_function_name
1616

17-
duration_by_test = {}
17+
duration_by_test.clear()
1818
stats_time = None
1919
config = None
2020
_stats = set()

mutmut/__main__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@ def execute_pytest(self, params: list[str], **kwargs):
417417

418418
def run_stats(self, *, tests):
419419
class StatsCollector:
420+
# noinspection PyMethodMayBeStatic
421+
def pytest_runtest_logstart(self, nodeid, location):
422+
mutmut.duration_by_test[nodeid] = 0
423+
420424
# noinspection PyMethodMayBeStatic
421425
def pytest_runtest_teardown(self, item, nextitem):
422426
unused(nextitem)
@@ -426,7 +430,7 @@ def pytest_runtest_teardown(self, item, nextitem):
426430

427431
# noinspection PyMethodMayBeStatic
428432
def pytest_runtest_makereport(self, item, call):
429-
mutmut.duration_by_test[item.nodeid] = call.duration
433+
mutmut.duration_by_test[item.nodeid] += call.duration
430434

431435
stats_collector = StatsCollector()
432436

0 commit comments

Comments
 (0)