Codebase list aiocoap / b624849
Add Python 3.7.1 compatibility patch Iñaki Malerba 5 years ago
3 changed file(s) with 65 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
66 * d/copyright: Use https protocol in Format field
77 * Use 'python3 -m sphinx' instead of sphinx-build for building docs
88
9 -- Agustin Henze <tin@debian.org> Fri, 15 Jun 2018 13:24:58 -0300
9 [ Iñaki Malerba ]
10 * Add Python 3.7.1 compatibility patch (Closes: #914835)
11
12 -- Iñaki Malerba <inaki@malerba.space> Tue, 01 Jan 2019 16:57:28 -0300
1013
1114 aiocoap (0.3-2) unstable; urgency=medium
1215
0 Description: Fix test fixture compatibility with Python 3.7.1
1 Python 3.7.1 requires logging handlers to be hashable now.
2 Author: Michael Hudson-Doyle <michael.hudson@ubuntu.com>
3 Origin: vendor
4 Bug: https://github.com/chrysn/aiocoap/issues/127
5 Last-Update: 2018-11-02
6 ---
7 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
8 --- a/tests/server.py
9 +++ b/tests/server.py
10 @@ -119,9 +119,9 @@
11 # tricking, and it interacts badly with WithLogMonitoring as they both
12 # try to change the root logger's level.
13
14 - startcount = len(self.handler)
15 + startcount = len(self.handler.list)
16 result = function(self, *args)
17 - messages = [m.msg for m in self.handler[startcount:] if m.levelno >= logging.WARNING]
18 + messages = [m.msg for m in self.handler.list[startcount:] if m.levelno >= logging.WARNING]
19 self.assertEqual(messages, expected_warnings, "Function %s had unexpected warnings: %s"%(function.__name__, messages))
20 return result
21 wrapped.__name__ = function.__name__
22 @@ -148,20 +148,23 @@
23 logging.root.removeHandler(self.handler)
24 #
25 # formatter = logging.Formatter(fmt='%(levelname)s:%(name)s:%(message)s')
26 -# print("fyi:\n", "\n".join(formatter.format(x) for x in self.handler if x.name != 'asyncio'))
27 +# print("fyi:\n", "\n".join(formatter.format(x) for x in self.handler.list if x.name != 'asyncio'))
28
29 - class ListHandler(logging.Handler, list):
30 + class ListHandler(logging.Handler):
31 + def __init__(self):
32 + super().__init__()
33 + self.list = []
34 def emit(self, record):
35 - self.append(record)
36 + self.list.append(record)
37
38 def assertWarned(self, message):
39 """Assert that there was a warning with the given message.
40
41 This function also removes the warning from the log, so an enclosing
42 @no_warnings (or @precise_warnings) can succed."""
43 - for entry in self.handler:
44 + for entry in self.handler.list:
45 if entry.msg == message and entry.levelno == logging.WARNING:
46 - self.handler.remove(entry)
47 + self.handler.list.remove(entry)
48 break
49 else:
50 raise AssertionError("Warning not logged: %r"%message)
51 @@ -202,7 +205,7 @@
52 else:
53 snapshotsmessage = snapshot1
54 formatter = logging.Formatter(fmt='%(levelname)s:%(name)s:%(message)s')
55 - errormessage = "Protocol %s was not garbage collected.\n\n"%attribute + snapshotsmessage + "\n\nLog of the unit test:\n" + "\n".join(formatter.format(x) for x in self.handler)
56 + errormessage = "Protocol %s was not garbage collected.\n\n"%attribute + snapshotsmessage + "\n\nLog of the unit test:\n" + "\n".join(formatter.format(x) for x in self.handler.list)
57 self.fail(errormessage)
58
59 class WithTestServer(WithAsyncLoop, Destructing):
0 py371-fix.patch