summaryrefslogtreecommitdiff
path: root/dev-python/django/files/django-3.2.19-py311.patch
blob: 976537289ff3e3df6cfbfb5dbd869b33869d7456 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
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

From 0981a4bc273e2a87ad10c602d9547e006e06d8dd Mon Sep 17 00:00:00 2001
From: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Date: Fri, 7 Apr 2023 11:07:54 +0200
Subject: [PATCH] Refs #34118 -- Fixed CustomChoicesTests.test_uuid_unsupported
 on Python 3.11.4+.

https://github.com/python/cpython/commit/5342f5e713e0cc45b6f226d2d053a8cde1b4d68e

Follow up to 38e63c9e61152682f3ff982c85a73793ab6d3267.
---
 tests/model_enums/tests.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/model_enums/tests.py b/tests/model_enums/tests.py
index ffc199ce42..c4ca6c91d7 100644
--- a/tests/model_enums/tests.py
+++ b/tests/model_enums/tests.py
@@ -259,7 +259,7 @@ class CustomChoicesTests(SimpleTestCase):
                 pass
 
     def test_uuid_unsupported(self):
-        msg = 'UUID objects are immutable'
-        with self.assertRaisesMessage(TypeError, msg):
+        with self.assertRaises(TypeError):
+
             class Identifier(uuid.UUID, models.Choices):
                 A = '972ce4eb-a95f-4a56-9339-68c208a76f18'
-- 
2.40.1