--- a/tests/test-util.py Sat Oct 05 10:29:34 2019 -0400
+++ b/tests/test-util.py Sun Oct 06 09:45:02 2019 -0400
@@ -7,6 +7,7 @@
from mercurial import pycompat, util, utils
+
@contextlib.contextmanager
def mocktimer(incr=0.1, *additional_targets):
"""Replaces util.timer and additional_targets with a mock
@@ -46,10 +47,12 @@
for args in additional_origs:
setattr(*args)
+
# attr.s default factory for util.timedstats.start binds the timer we
# need to mock out.
_start_default = (util.timedcmstats.start.default, 'factory')
+
@contextlib.contextmanager
def capturestderr():
"""Replace utils.procutil.stderr with a pycompat.bytesio instance
@@ -66,6 +69,7 @@
finally:
utils.procutil.stderr = orig
+
class timedtests(unittest.TestCase):
def testtimedcmstatsstr(self):
stats = util.timedcmstats()
@@ -127,11 +131,13 @@
with capturestderr() as out:
testfunc(2)
- self.assertEqual(out.getvalue(), (
- b' testfunc: 1.000 s\n'
- b' testfunc: 3.000 s\n'
- ))
+ self.assertEqual(
+ out.getvalue(),
+ (b' testfunc: 1.000 s\n' b' testfunc: 3.000 s\n'),
+ )
+
if __name__ == '__main__':
import silenttestrunner
+
silenttestrunner.main(__name__)