Skip to content

Commit b7bfcc4

Browse files
danchrdnozay
authored andcommitted
bypass freezegun if installed (#185)
freezegun is simple package frequently used in tests to stop the clock. When active on a class, xmlrunner reports that all its tests took zero seconds, which is obviously incorrect. To easily bypass this without making the code aware of freezegun, we import `time.time()` by value.
1 parent ed3fb0b commit b7bfcc4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

xmlrunner/result.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
from os import path
1111
from six.moves import StringIO
1212

13+
# use direct import to bypass freezegun
14+
from time import time
15+
1316
from .unittest import TestResult, _TextTestResult, failfast
1417

1518

@@ -247,7 +250,7 @@ def startTest(self, test):
247250
"""
248251
Called before execute each test method.
249252
"""
250-
self.start_time = time.time()
253+
self.start_time = time()
251254
TestResult.startTest(self, test)
252255

253256
if self.showAll:
@@ -294,7 +297,7 @@ def stopTest(self, test):
294297
# self._stderr_data = sys.stderr.getvalue()
295298

296299
_TextTestResult.stopTest(self, test)
297-
self.stop_time = time.time()
300+
self.stop_time = time()
298301

299302
if self.callback and callable(self.callback):
300303
self.callback()

0 commit comments

Comments
 (0)