Mercurial > hg
diff tests/test-util.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | 331ab85e910b |
children | 5aafc3c5bdec |
line wrap: on
line diff
--- 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__)