summaryrefslogtreecommitdiff
path: root/Lib/test/test_regrtest.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-06-27 00:44:43 +0200
committerGitHub <noreply@github.com>2018-06-27 00:44:43 +0200
commit1d55888a78bcefed3723fb7e48df2a75b4f0adb0 (patch)
tree48a61bb00d3deb15112ff1c16edfe9bf11ddda9e /Lib/test/test_regrtest.py
parentc6040638aa1537709add895d24cdbbb9ee310fde (diff)
downloadcpython-git-1d55888a78bcefed3723fb7e48df2a75b4f0adb0.tar.gz
bpo-33873: Backport regrtest from master to 3.7 (GH-7935) (GH-7937)
* 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() (cherry picked from commit 4ffe9c2b251f6e027b26250b7a2618e78d4edd22) * bpo-33873: regrtest: Add warning on -R 1:3 (GH-7736) regrtest: Add warning when using less than 3 warmup runs like -R 1:3. (cherry picked from commit cac4fef8860e66a9da67d09762f5b614b9471a12) * bpo-33873: Fix bug in `runtest.py` and add checks for invalid `-R` parameters (GH-7735) Fix bug in `Lib/test/libregrtest/runtest.py` that makes running tests an extra time than the specified number of runs. Add check for invalid --huntrleaks/-R parameters. (cherry picked from commit 58ed7307ea0b5c5aa052291ebc3030f314f938d8) (cherry picked from commit d1f9481b7a2d31c40fca1347ef99d819eb656ce7)
Diffstat (limited to 'Lib/test/test_regrtest.py')
-rw-r--r--Lib/test/test_regrtest.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index e2b52283cd..0b590ad8f1 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -18,6 +18,7 @@ import textwrap
import unittest
from test import libregrtest
from test import support
+from test.libregrtest import utils
Py_DEBUG = hasattr(sys, 'getobjects')
@@ -984,5 +985,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()