summaryrefslogtreecommitdiff
path: root/dev-python/twisted/files/twisted-22.10.0-python3.11-tests.patch
blob: b75c97d4997fa3a0d1c51c6c28ac686271770f41 (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
https://src.fedoraproject.org/rpms/python-twisted/blob/rawhide/f/0003-Fix-tests-for-Python-3.11.patch

From b0574816f622bc187389df2183e2bef0492fe5f5 Mon Sep 17 00:00:00 2001
From: eevel <eevel@weezel3.weezelnet>
Date: Wed, 2 Nov 2022 20:35:55 -0500
Subject: [PATCH 3/6] Fix tests for Python 3.11

This is based on a subset of commits from this pull request.

https://github.com/twisted/twisted/pull/11734

- fix twisted.persisted tests (cherry picked from commit 4f6d7fb0749429b092fe7538a7d2b11fe58319a6)
- fix tests for twisted.spread (cherry picked from commit 525377178adfa987ed56be753aec0fce35d721dc)
- fix test for twisted.web (cherry picked from commit afcc224a02f72e5d12fa35d223bd753e8086b135)
- fix persisted tests in twisted.test (cherry picked from commit 4b5ab38b09b326cec7967e04bd4cae8a84bb6784)
- fix twisted.trial tests (cherry picked from commit f8f56d45113e5f2467a5e8375186e5db6309dfc6)
- make test_flatten backwards-compatible (cherry picked from commit d91675ac5ffe907fcdbb3d1cedb1240008d81fd1)
--- a/src/twisted/persisted/aot.py
+++ b/src/twisted/persisted/aot.py
@@ -399,8 +399,10 @@ class AOTUnjellier:
                 inst = klass.__new__(klass)
                 if hasattr(klass, "__setstate__"):
                     self.callAfter(inst.__setstate__, state)
-                else:
+                elif isinstance(state, dict):
                     inst.__dict__ = state
+                else:
+                    inst.__dict__ = state.__getstate__()
                 return inst
 
             elif c is Ref:
--- a/src/twisted/spread/flavors.py
+++ b/src/twisted/spread/flavors.py
@@ -398,6 +398,8 @@ class RemoteCopy(Unjellyable):
         object's dictionary (or a filtered approximation of it depending
         on my peer's perspective).
         """
+        if not state:
+            state = {}
         state = {
             x.decode("utf8") if isinstance(x, bytes) else x: y for x, y in state.items()
         }
--- a/src/twisted/spread/jelly.py
+++ b/src/twisted/spread/jelly.py
@@ -154,7 +154,8 @@ def _newInstance(cls, state):
     instance = _createBlank(cls)
 
     def defaultSetter(state):
-        instance.__dict__ = state
+        if isinstance(state, dict):
+            instance.__dict__ = state or {}
 
     setter = getattr(instance, "__setstate__", defaultSetter)
     setter(state)
--- a/src/twisted/test/test_persisted.py
+++ b/src/twisted/test/test_persisted.py
@@ -378,6 +378,10 @@ class AOTTests(TestCase):
             def __dict__(self):
                 raise AttributeError()
 
+            @property
+            def __getstate__(self):
+                raise AttributeError()
+
         self.assertRaises(TypeError, aot.jellyToSource, UnknownType())
 
     def test_basicIdentity(self):
--- a/src/twisted/trial/test/test_pyunitcompat.py
+++ b/src/twisted/trial/test/test_pyunitcompat.py
@@ -218,8 +218,10 @@ class PyUnitResultTests(SynchronousTestCase):
         pyresult = pyunit.TestResult()
         result = PyUnitResultAdapter(pyresult)
         result.addError(self, f)
+        tback = "".join(traceback.format_exception(*exc_info))
         self.assertEqual(
-            pyresult.errors[0][1], "".join(traceback.format_exception(*exc_info))
+            pyresult.errors[0][1].endswith("ZeroDivisionError: division by zero\n"),
+            tback.endswith("ZeroDivisionError: division by zero\n"),
         )
 
     def test_trialSkip(self):
--- a/src/twisted/web/test/test_flatten.py
+++ b/src/twisted/web/test/test_flatten.py
@@ -706,10 +706,9 @@ class FlattenerErrorTests(SynchronousTestCase):
                     Exception while flattening:
                       \\[<unrenderable>\\]
                       <unrenderable>
-                      .*
+                      <Deferred at .* current result: <twisted.python.failure.Failure builtins.RuntimeError: example>>
                       File ".*", line \\d*, in _flattenTree
-                        element = await element
-                    RuntimeError: example
+                        element = await element.*
                     """
                 ),
                 flags=re.MULTILINE,
-- 
2.39.2