1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #34210 -- Added unittest's durations option to the test runner.

This commit is contained in:
David Smith
2023-06-14 19:22:48 +01:00
committed by Mariusz Felisiak
parent 27b399d235
commit 74b5074174
8 changed files with 110 additions and 5 deletions

View File

@@ -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)])