Skip to content

Commit

Permalink
Fix twisted.logger.test.test_format.EventAsTextTests.test_formatTrace…
Browse files Browse the repository at this point in the history
…backHandlesUTF8DecodeFailure

Resolve this failure:

    Traceback (most recent call last):
      File "/home/twm/dev/twisted/build/nocov/lib/python3.6/site-packages/twisted/logger/test/test_format.py", line 531, in test_formatTracebackHandlesUTF8DecodeFailure
        self.assertIn(r"CapturedError(b'\xff\xfet\x00e\x00s\x00t\x00')", eventText)
      File "/home/twm/dev/twisted/build/nocov/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 489, in assertIn
        raise self.failureException(msg or "%r not in %r" % (containee, container))
    twisted.trial.unittest.FailTest: "CapturedError(b'\\xff\\xfet\\x00e\\x00s\\x00t\\x00')" not in '- This is a test log message\nTraceback (most recent call last):\n  File "/home/twm/dev/twisted/build/nocov/lib/python3.6/site-packages/twisted/trial/_asynctest.py", line 148, in deferTestMethod\n    d = self._run(self._testMethodName, result)\n  File "/home/twm/dev/twisted/build/nocov/lib/python3.6/site-packages/twisted/trial/_asynctest.py", line 119, in _run\n    utils.runWithWarningsSuppressed, self._getSuppress(), method\n  File "/home/twm/dev/twisted/build/nocov/lib/python3.6/site-packages/twisted/internet/defer.py", line 162, in maybeDeferred\n    result = f(*args, **kw)\n  File "/home/twm/dev/twisted/build/nocov/lib/python3.6/site-packages/twisted/internet/utils.py", line 205, in runWithWarningsSuppressed\n    result = f(*a, **kw)\n--- <exception caught here> ---\n  File "/home/twm/dev/twisted/build/nocov/lib/python3.6/site-packages/twisted/logger/test/test_format.py", line 523, in test_formatTracebackHandlesUTF8DecodeFailure\n    raise CapturedError(b"\\xff\\xfet\\x00e\\x00s\\x00t\\x00")\ntwisted.logger.test.test_format.CapturedError: b\'\\xff\\xfet\\x00e\\x00s\\x00t\\x00\'\n'

The solution is to update the expectation to use the double quotes Black
has changed the code to use.
  • Loading branch information
twm committed Sep 13, 2020
1 parent 3d60a85 commit 2311807
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/twisted/logger/test/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def test_formatTracebackHandlesUTF8DecodeFailure(self):
event["log_failure"] = f
eventText = eventAsText(event, includeTimestamp=True, includeSystem=False)
self.assertIn("Traceback", eventText)
self.assertIn(r"CapturedError(b'\xff\xfet\x00e\x00s\x00t\x00')", eventText)
self.assertIn(r'CapturedError(b"\xff\xfet\x00e\x00s\x00t\x00")', eventText)

def test_eventAsTextSystemOnly(self):
"""
Expand Down

0 comments on commit 2311807

Please sign in to comment.