summaryrefslogtreecommitdiff
path: root/tests/test_runner
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2025-01-17 22:09:56 +0100
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-01-20 14:07:28 +0100
commitf5772de69679efb54129ac1cbca3579b512778af (patch)
treeab215760e2e77124bbb8970b0913c2a99ae68743 /tests/test_runner
parent61dae11df52fae71fc3050974ac459f362c9dfd7 (diff)
Fixed #36005 -- Dropped support for Python 3.10 and 3.11.
Diffstat (limited to 'tests/test_runner')
-rw-r--r--tests/test_runner/test_debug_sql.py13
-rw-r--r--tests/test_runner/test_discover_runner.py3
-rw-r--r--tests/test_runner/test_parallel.py13
-rw-r--r--tests/test_runner/tests.py15
4 files changed, 9 insertions, 35 deletions
diff --git a/tests/test_runner/test_debug_sql.py b/tests/test_runner/test_debug_sql.py
index e7e8d14fbd..27fc4001c2 100644
--- a/tests/test_runner/test_debug_sql.py
+++ b/tests/test_runner/test_debug_sql.py
@@ -4,7 +4,6 @@ from io import StringIO
from django.db import connection
from django.test import TestCase
from django.test.runner import DiscoverRunner
-from django.utils.version import PY311
from .models import Person
@@ -114,17 +113,15 @@ class TestDebugSQL(unittest.TestCase):
),
]
- # Python 3.11 uses fully qualified test name in the output.
- method_name = ".runTest" if PY311 else ""
test_class_path = "test_runner.test_debug_sql.TestDebugSQL"
verbose_expected_outputs = [
- f"runTest ({test_class_path}.FailingTest{method_name}) ... FAIL",
- f"runTest ({test_class_path}.ErrorTest{method_name}) ... ERROR",
- f"runTest ({test_class_path}.PassingTest{method_name}) ... ok",
+ f"runTest ({test_class_path}.FailingTest.runTest) ... FAIL",
+ f"runTest ({test_class_path}.ErrorTest.runTest) ... ERROR",
+ f"runTest ({test_class_path}.PassingTest.runTest) ... ok",
# If there are errors/failures in subtests but not in test itself,
# the status is not written. That behavior comes from Python.
- f"runTest ({test_class_path}.FailingSubTest{method_name}) ...",
- f"runTest ({test_class_path}.ErrorSubTest{method_name}) ...",
+ f"runTest ({test_class_path}.FailingSubTest.runTest) ...",
+ f"runTest ({test_class_path}.ErrorSubTest.runTest) ...",
(
"""SELECT COUNT(*) AS "__count"\n"""
"""FROM "test_runner_person"\nWHERE """
diff --git a/tests/test_runner/test_discover_runner.py b/tests/test_runner/test_discover_runner.py
index 4f13cceeff..4c4a22397b 100644
--- a/tests/test_runner/test_discover_runner.py
+++ b/tests/test_runner/test_discover_runner.py
@@ -16,7 +16,6 @@ from django.test.utils import (
captured_stderr,
captured_stdout,
)
-from django.utils.version import PY312
@contextmanager
@@ -768,7 +767,6 @@ class DiscoverRunnerTests(SimpleTestCase):
failures = runner.suite_result(suite, result)
self.assertEqual(failures, expected_failures)
- @unittest.skipUnless(PY312, "unittest --durations option requires Python 3.12")
def test_durations(self):
with captured_stderr() as stderr, captured_stdout():
runner = DiscoverRunner(durations=10)
@@ -776,7 +774,6 @@ class DiscoverRunnerTests(SimpleTestCase):
runner.run_suite(suite)
self.assertIn("Slowest test durations", stderr.getvalue())
- @unittest.skipUnless(PY312, "unittest --durations option requires Python 3.12")
def test_durations_debug_sql(self):
with captured_stderr() as stderr, captured_stdout():
runner = DiscoverRunner(durations=10, debug_sql=True)
diff --git a/tests/test_runner/test_parallel.py b/tests/test_runner/test_parallel.py
index 5026bc36c5..3af0fbf2f9 100644
--- a/tests/test_runner/test_parallel.py
+++ b/tests/test_runner/test_parallel.py
@@ -7,7 +7,6 @@ from unittest.suite import TestSuite, _ErrorHolder
from django.test import SimpleTestCase
from django.test.runner import ParallelTestSuite, RemoteTestResult
-from django.utils.version import PY311, PY312
try:
import tblib.pickling_support
@@ -193,27 +192,21 @@ class RemoteTestResultTest(SimpleTestCase):
subtest_test.run(result=result)
events = result.events
- # addDurations added in Python 3.12.
- if PY312:
- self.assertEqual(len(events), 5)
- else:
- self.assertEqual(len(events), 4)
+ self.assertEqual(len(events), 5)
self.assertIs(result.wasSuccessful(), False)
event = events[1]
self.assertEqual(event[0], "addSubTest")
self.assertEqual(
str(event[2]),
- "dummy_test (test_runner.test_parallel.SampleFailingSubtest%s) (index=0)"
- # Python 3.11 uses fully qualified test name in the output.
- % (".dummy_test" if PY311 else ""),
+ "dummy_test (test_runner.test_parallel.SampleFailingSubtest.dummy_test) "
+ "(index=0)",
)
self.assertEqual(repr(event[3][1]), "AssertionError('0 != 1')")
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)
diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py
index fba8dd3b6f..d66ece4005 100644
--- a/tests/test_runner/tests.py
+++ b/tests/test_runner/tests.py
@@ -15,7 +15,7 @@ from django import db
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
-from django.core.management.base import CommandError, SystemCheckError
+from django.core.management.base import SystemCheckError
from django.test import SimpleTestCase, TransactionTestCase, skipUnlessDBFeature
from django.test.runner import (
DiscoverRunner,
@@ -32,7 +32,6 @@ from django.test.utils import (
get_unique_databases_and_mirrors,
iter_test_cases,
)
-from django.utils.version import PY312
from .models import B, Person, Through
@@ -479,7 +478,6 @@ class ManageCommandTests(unittest.TestCase):
)
self.assertIn("Total run took", stderr.getvalue())
- @unittest.skipUnless(PY312, "unittest --durations option requires Python 3.12")
def test_durations(self):
with captured_stderr() as stderr:
call_command(
@@ -490,17 +488,6 @@ class ManageCommandTests(unittest.TestCase):
)
self.assertIn("durations=10", stderr.getvalue())
- @unittest.skipIf(PY312, "unittest --durations option requires Python 3.12")
- def test_durations_lt_py312(self):
- msg = "Error: unrecognized arguments: --durations=10"
- with self.assertRaises(CommandError, msg=msg):
- call_command(
- "test",
- "--durations=10",
- "sites",
- testrunner="test_runner.tests.MockTestRunner",
- )
-
# Isolate from the real environment.
@mock.patch.dict(os.environ, {}, clear=True)