def test_observeFailure(self):
        """
        If the C{"log_failure"} key exists in an event, the observer appends
        the failure's traceback to the output.
        """
        with StringIO() as fileHandle:
            observer = textFileLogObserver(fileHandle)

            try:
                1 / 0
            except ZeroDivisionError:
                failure = Failure()

            event = dict(log_failure=failure)
            observer(event)
            output = fileHandle.getvalue()
            self.assertTrue(output.split("\n")[1].startswith("\tTraceback "),
                            msg=repr(output))

        If the C{"log_failure"} key exists in an event, the observer appends
        the failure's traceback to the output.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/logger/test/test_file.py