diff options
| author | David Smith <smithdc@gmail.com> | 2023-06-14 19:22:48 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-08-31 07:14:58 +0200 |
| commit | 74b5074174d1749ee44df2f7ed418010a7a4ac70 (patch) | |
| tree | a533ff3b0e3db36baa991081d012d4554acbef28 /tests/test_runner/test_parallel.py | |
| parent | 27b399d23531541d091886f683991e321c8fa314 (diff) | |
Fixed #34210 -- Added unittest's durations option to the test runner.
Diffstat (limited to 'tests/test_runner/test_parallel.py')
| -rw-r--r-- | tests/test_runner/test_parallel.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/test_runner/test_parallel.py b/tests/test_runner/test_parallel.py index eea9e4de74..e83f53bf4e 100644 --- a/tests/test_runner/test_parallel.py +++ b/tests/test_runner/test_parallel.py @@ -4,7 +4,7 @@ import unittest from django.test import SimpleTestCase from django.test.runner import RemoteTestResult -from django.utils.version import PY311 +from django.utils.version import PY311, PY312 try: import tblib.pickling_support @@ -118,7 +118,11 @@ class RemoteTestResultTest(SimpleTestCase): subtest_test.run(result=result) events = result.events - self.assertEqual(len(events), 4) + # addDurations added in Python 3.12. + if PY312: + self.assertEqual(len(events), 5) + else: + self.assertEqual(len(events), 4) self.assertIs(result.wasSuccessful(), False) event = events[1] @@ -133,3 +137,9 @@ class RemoteTestResultTest(SimpleTestCase): event = events[2] self.assertEqual(repr(event[3][1]), "AssertionError('2 != 1')") + + @unittest.skipUnless(PY312, "unittest --durations option requires Python 3.12") + def test_add_duration(self): + result = RemoteTestResult() + result.addDuration(None, 2.3) + self.assertEqual(result.collectedDurations, [("None", 2.3)]) |
