diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-06-14 12:58:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-14 12:58:13 (GMT) |
commit | 4ffe9c2b251f6e027b26250b7a2618e78d4edd22 (patch) | |
tree | 513f1108f7b17cfddebda68d49d5e58b47b54397 /Lib/test/test_regrtest.py | |
parent | dfa9643d292dcaa14cbf3c44b8330ba2159976c0 (diff) | |
download | cpython-4ffe9c2b251f6e027b26250b7a2618e78d4edd22.zip cpython-4ffe9c2b251f6e027b26250b7a2618e78d4edd22.tar.gz cpython-4ffe9c2b251f6e027b26250b7a2618e78d4edd22.tar.bz2 |
bpo-33718: regrtest: use format_duration() to display failed tests (GH-7686)
* Enhance also format_duration(): work on integers and rounds towards
+infinity (math.ceil).
* Write unit tests on format_duration()
Diffstat (limited to 'Lib/test/test_regrtest.py')
-rw-r--r-- | Lib/test/test_regrtest.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py index 1041152..af332ad 100644 --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -19,6 +19,7 @@ import threading import unittest from test import libregrtest from test import support +from test.libregrtest import utils Py_DEBUG = hasattr(sys, 'getobjects') @@ -980,5 +981,29 @@ class ArgsTestCase(BaseTestCase): failed=testname, rerun=testname) +class TestUtils(unittest.TestCase): + def test_format_duration(self): + self.assertEqual(utils.format_duration(0), + '0 ms') + self.assertEqual(utils.format_duration(1e-9), + '1 ms') + self.assertEqual(utils.format_duration(10e-3), + '10 ms') + self.assertEqual(utils.format_duration(1.5), + '1 sec 500 ms') + self.assertEqual(utils.format_duration(1), + '1 sec') + self.assertEqual(utils.format_duration(2 * 60), + '2 min') + self.assertEqual(utils.format_duration(2 * 60 + 1), + '2 min 1 sec') + self.assertEqual(utils.format_duration(3 * 3600), + '3 hour') + self.assertEqual(utils.format_duration(3 * 3600 + 2 * 60 + 1), + '3 hour 2 min') + self.assertEqual(utils.format_duration(3 * 3600 + 1), + '3 hour 1 sec') + + if __name__ == '__main__': unittest.main() |