def test_formatTracebackHandlesUTF8DecodeFailure(self):
        """
        An error raised attempting to decode the UTF still produces a
        valid log message.
        """
        try:
            # 'test' in utf-16
            raise CapturedError(b'\xff\xfet\x00e\x00s\x00t\x00')
        except CapturedError:
            f = Failure()

        event = {
            "log_format": u"This is a test log message"
        }
        event["log_failure"] = f
        eventText = eventAsText(
            event,
            includeTimestamp=True,
            includeSystem=False
        )
        self.assertIn(u'Traceback', eventText)
        if not _PY3:
            self.assertIn(u'\ufffd\ufffdt\x00e\x00s\x00t\x00', eventText)
        else:
            self.assertIn(
                r"CapturedError(b'\xff\xfet\x00e\x00s\x00t\x00')",
                eventText
            )

        An error raised attempting to decode the UTF still produces a
        valid log message.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/logger/test/test_format.py