summaryrefslogtreecommitdiff
path: root/dev-python/django/files/django-3.2.18-py311.patch
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/django/files/django-3.2.18-py311.patch')
-rw-r--r--dev-python/django/files/django-3.2.18-py311.patch153
1 files changed, 153 insertions, 0 deletions
diff --git a/dev-python/django/files/django-3.2.18-py311.patch b/dev-python/django/files/django-3.2.18-py311.patch
new file mode 100644
index 000000000000..2cebb8cc817b
--- /dev/null
+++ b/dev-python/django/files/django-3.2.18-py311.patch
@@ -0,0 +1,153 @@
+From 2882cf6f184c7578219e2b5266623e82c0e9b8a2 Mon Sep 17 00:00:00 2001
+From: Mariusz Felisiak <felisiak.mariusz@gmail.com>
+Date: Thu, 7 Apr 2022 07:02:21 +0200
+Subject: [PATCH] Refs #33173 -- Fixed test_runner/test_utils tests on Python
+ 3.11+.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Python 3.11 uses fully qualified test name in unittest output. See
+https://github.com/python/cpython/commit/755be9b1505af591b9f2ee424a6525b6c2b65ce9
+
+(rebased by Michał Górny)
+---
+ django/utils/version.py | 1 +
+ tests/test_runner/test_debug_sql.py | 30 ++++++++++++++++++-----------
+ tests/test_runner/test_parallel.py | 11 ++++++++---
+ tests/test_utils/tests.py | 9 +++++++--
+ 4 files changed, 35 insertions(+), 16 deletions(-)
+
+diff --git a/django/utils/version.py b/django/utils/version.py
+index 74c327525e..0c2bfc626e 100644
+--- a/django/utils/version.py
++++ b/django/utils/version.py
+@@ -15,6 +15,7 @@ PY37 = sys.version_info >= (3, 7)
+ PY38 = sys.version_info >= (3, 8)
+ PY39 = sys.version_info >= (3, 9)
+ PY310 = sys.version_info >= (3, 10)
++PY311 = sys.version_info >= (3, 11)
+
+
+ def get_version(version=None):
+diff --git a/tests/test_runner/test_debug_sql.py b/tests/test_runner/test_debug_sql.py
+index 0e8e4207d6..2b5fed7a76 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
+
+@@ -100,20 +101,27 @@ class TestDebugSQL(unittest.TestCase):
+ '''"test_runner_person"."first_name" = 'subtest-fail';'''),
+ ]
+
++ # 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) ...',
+- ('''SELECT COUNT(*) AS "__count" '''
+- '''FROM "test_runner_person" WHERE '''
+- '''"test_runner_person"."first_name" = 'pass';'''),
+- ('''SELECT COUNT(*) AS "__count" '''
+- '''FROM "test_runner_person" WHERE '''
+- '''"test_runner_person"."first_name" = 'subtest-pass';'''),
++ 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 """
++ """"test_runner_person"."first_name" = 'pass';"""
++ ),
++ (
++ """SELECT COUNT(*) AS "__count" """
++ """FROM "test_runner_person" WHERE """
++ """"test_runner_person"."first_name" = 'subtest-pass';"""
++ ),
+ ]
+
+ def test_setupclass_exception(self):
+diff --git a/tests/test_runner/test_parallel.py b/tests/test_runner/test_parallel.py
+index c1a89bd0f0..0f1adcf208 100644
+--- a/tests/test_runner/test_parallel.py
++++ b/tests/test_runner/test_parallel.py
+@@ -2,7 +2,7 @@ import unittest
+
+ from django.test import SimpleTestCase
+ from django.test.runner import RemoteTestResult
+-from django.utils.version import PY37
++from django.utils.version import PY37, PY311
+
+ try:
+ import tblib
+@@ -78,8 +78,13 @@ class RemoteTestResultTest(SimpleTestCase):
+ self.assertEqual(len(events), 4)
+
+ event = events[1]
+- self.assertEqual(event[0], 'addSubTest')
+- self.assertEqual(str(event[2]), 'dummy_test (test_runner.test_parallel.SampleFailingSubtest) (index=0)')
++ 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 ""),
++ )
+ trailing_comma = '' if PY37 else ','
+ self.assertEqual(repr(event[3][1]), "AssertionError('0 != 1'%s)" % trailing_comma)
+
+diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
+index 9255315e98..8f72057afe 100644
+--- a/tests/test_utils/tests.py
++++ b/tests/test_utils/tests.py
+@@ -26,6 +26,7 @@ from django.test.utils import (
+ )
+ from django.urls import NoReverseMatch, path, reverse, reverse_lazy
+ from django.utils.deprecation import RemovedInDjango41Warning
++from django.utils.version import PY311
+
+ from .models import Car, Person, PossessedCar
+ from .views import empty_response
+@@ -78,9 +79,11 @@ class SkippingTestCase(SimpleTestCase):
+ SkipTestCase('test_foo').test_foo,
+ ValueError,
+ "skipUnlessDBFeature cannot be used on test_foo (test_utils.tests."
+- "SkippingTestCase.test_skip_unless_db_feature.<locals>.SkipTestCase) "
++ "SkippingTestCase.test_skip_unless_db_feature.<locals>.SkipTestCase%s) "
+ "as SkippingTestCase.test_skip_unless_db_feature.<locals>.SkipTestCase "
+ "doesn't allow queries against the 'default' database."
++ # Python 3.11 uses fully qualified test name in the output.
++ % (".test_foo" if PY311 else ""),
+ )
+
+ def test_skip_if_db_feature(self):
+@@ -122,9 +125,11 @@ class SkippingTestCase(SimpleTestCase):
+ SkipTestCase('test_foo').test_foo,
+ ValueError,
+ "skipIfDBFeature cannot be used on test_foo (test_utils.tests."
+- "SkippingTestCase.test_skip_if_db_feature.<locals>.SkipTestCase) "
++ "SkippingTestCase.test_skip_if_db_feature.<locals>.SkipTestCase%s) "
+ "as SkippingTestCase.test_skip_if_db_feature.<locals>.SkipTestCase "
+ "doesn't allow queries against the 'default' database."
++ # Python 3.11 uses fully qualified test name in the output.
++ % (".test_foo" if PY311 else ""),
+ )
+
+
+--
+2.40.0
+