Merge ~d0ugal/maas:testtools-monkeypatch into maas:master

Proposed by Dougal Matthews
Status: Merged
Approved by: Dougal Matthews
Approved revision: 3bea79fdd5d3f0f1b8f88e0677f3f16963072bed
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~d0ugal/maas:testtools-monkeypatch
Merge into: maas:master
Diff against target: 54 lines (+0/-26)
2 files modified
src/maastesting/__init__.py (+0/-8)
src/maastesting/twisted.py (+0/-18)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Alberto Donato (community) Approve
Review via email: mp+393565@code.launchpad.net

Commit message

Remove the testtools monkeypatch that maybe fixed a bug

The upstream fix was landed in 2016 and included in testtools 2.4.0

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

+1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b testtools-monkeypatch lp:~d0ugal/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/8655/console
COMMIT: 626bd4a707e99aebfa47f184e6bd001cad794093

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b testtools-monkeypatch lp:~d0ugal/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 3bea79fdd5d3f0f1b8f88e0677f3f16963072bed

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maastesting/__init__.py b/src/maastesting/__init__.py
index 8d8856c..6133ab5 100644
--- a/src/maastesting/__init__.py
+++ b/src/maastesting/__init__.py
@@ -44,11 +44,3 @@ filterwarnings("ignore", category=DeprecationWarning, module=r"^twisted\b")
44sentinel_type = type(mock.sentinel.foo)44sentinel_type = type(mock.sentinel.foo)
45copy._copy_dispatch[sentinel_type] = copy._copy_immutable45copy._copy_dispatch[sentinel_type] = copy._copy_immutable
46copy._deepcopy_dispatch[sentinel_type] = copy._copy_immutable46copy._deepcopy_dispatch[sentinel_type] = copy._copy_immutable
47
48# Monkey-patch test dependencies here.
49from maastesting.twisted import ( # noqa:E402 isort:skip
50 maybe_fix_bug_230_in_CaptureTwistedLogs,
51)
52
53maybe_fix_bug_230_in_CaptureTwistedLogs()
54del maybe_fix_bug_230_in_CaptureTwistedLogs
diff --git a/src/maastesting/twisted.py b/src/maastesting/twisted.py
index 7983106..ef5ae2b 100644
--- a/src/maastesting/twisted.py
+++ b/src/maastesting/twisted.py
@@ -11,12 +11,9 @@ __all__ = [
11]11]
1212
13from copy import copy13from copy import copy
14import inspect
15from textwrap import dedent
1614
17from fixtures import Fixture15from fixtures import Fixture
18from testtools.content import Content, UTF8_TEXT16from testtools.content import Content, UTF8_TEXT
19from testtools.deferredruntest import CaptureTwistedLogs
20from testtools.monkey import patch17from testtools.monkey import patch
21from testtools.twistedsupport._deferred import extract_result18from testtools.twistedsupport._deferred import extract_result
22from twisted.internet import defer19from twisted.internet import defer
@@ -24,21 +21,6 @@ from twisted.logger import formatEvent, globalLogPublisher, LogLevel
24from twisted.python import log21from twisted.python import log
2522
2623
27def maybe_fix_bug_230_in_CaptureTwistedLogs():
28 """Fix a bug in testtools's `CaptureTwistedLogs`.
29
30 Specifically "TypeError: CaptureTwistedLogs puts strings into details",
31 https://github.com/testing-cabal/testtools/issues/230. At the time of
32 writing this has been fixed upstream but not released.
33 """
34 source = inspect.getsource(CaptureTwistedLogs._setUp)
35 if "[logs.getvalue()]" in source:
36 source = source.replace("getvalue()", "getvalue().encode('utf-8')")
37 namespace = CaptureTwistedLogs._setUp.__globals__.copy()
38 exec(dedent(source), namespace)
39 CaptureTwistedLogs._setUp = namespace["_setUp"]
40
41
42class TwistedLoggerFixture(Fixture):24class TwistedLoggerFixture(Fixture):
43 """Capture all Twisted logging.25 """Capture all Twisted logging.
4426

Subscribers

People subscribed via source and target branches