From 2ee4caf56b8e000cabbb73ad81ff05738d6d0a35 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Thu, 7 Apr 2022 07:02:21 +0200 Subject: Refs #33173 -- Fixed test_runner/test_utils tests on Python 3.11+. Python 3.11 uses fully qualified test name in unittest output. See https://github.com/python/cpython/commit/755be9b1505af591b9f2ee424a6525b6c2b65ce9 --- tests/test_runner/test_debug_sql.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tests/test_runner/test_debug_sql.py') diff --git a/tests/test_runner/test_debug_sql.py b/tests/test_runner/test_debug_sql.py index 9957295f01..d45d8cb4ba 100644 --- a/tests/test_runner/test_debug_sql.py +++ b/tests/test_runner/test_debug_sql.py @@ -4,6 +4,7 @@ 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 @@ -109,14 +110,17 @@ 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 = [ - "runTest (test_runner.test_debug_sql.TestDebugSQL.FailingTest) ... FAIL", - "runTest (test_runner.test_debug_sql.TestDebugSQL.ErrorTest) ... ERROR", - "runTest (test_runner.test_debug_sql.TestDebugSQL.PassingTest) ... ok", + 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", # If there are errors/failures in subtests but not in test itself, # the status is not written. That behavior comes from Python. - "runTest (test_runner.test_debug_sql.TestDebugSQL.FailingSubTest) ...", - "runTest (test_runner.test_debug_sql.TestDebugSQL.ErrorSubTest) ...", + f"runTest ({test_class_path}.FailingSubTest{method_name}) ...", + f"runTest ({test_class_path}.ErrorSubTest{method_name}) ...", ( """SELECT COUNT(*) AS "__count" """ """FROM "test_runner_person" WHERE """ -- cgit v1.3