def test_failureFormatting(self) -> None:
    '\n        A L{FileLogObserver} created by L{jsonFileLogObserver} writes failures\n        serialized as JSON text to a file when it observes events.\n        '
    io = StringIO()
    publisher = LogPublisher()
    logged: List[LogEvent] = []
    publisher.addObserver(cast(ILogObserver, logged.append))
    publisher.addObserver(jsonFileLogObserver(io))
    logger = Logger(observer=publisher)
    try:
        (1 / 0)
    except BaseException:
        logger.failure('failed as expected')
    reader = StringIO(io.getvalue())
    deserialized = list(eventsFromJSONLogFile(reader))

    def checkEvents(logEvents: Sequence[LogEvent]) -> None:
        self.assertEqual(len(logEvents), 1)
        [failureEvent] = logEvents
        self.assertIn('log_failure', failureEvent)
        failureObject = failureEvent['log_failure']
        self.assertIsInstance(failureObject, Failure)
        tracebackObject = failureObject.getTracebackObject()
        self.assertEqual(tracebackObject.tb_frame.f_code.co_filename.rstrip('co'), __file__.rstrip('co'))
    checkEvents(logged)
    checkEvents(deserialized)
A L{FileLogObserver} created by L{jsonFileLogObserver} writes failures
serialized as JSON text to a file when it observes events.
def test_failureFormatting(self) -> None:
    '\n        A L{FileLogObserver} created by L{jsonFileLogObserver} writes failures\n        serialized as JSON text to a file when it observes events.\n        '
    io = StringIO()
    publisher = LogPublisher()
    logged: List[LogEvent] = []
    publisher.addObserver(cast(ILogObserver, logged.append))
    publisher.addObserver(jsonFileLogObserver(io))
    logger = Logger(observer=publisher)
    try:
        (1 / 0)
    except BaseException:
        logger.failure('failed as expected')
    reader = StringIO(io.getvalue())
    deserialized = list(eventsFromJSONLogFile(reader))

    def checkEvents(logEvents: Sequence[LogEvent]) -> None:
        self.assertEqual(len(logEvents), 1)
        [failureEvent] = logEvents
        self.assertIn('log_failure', failureEvent)
        failureObject = failureEvent['log_failure']
        self.assertIsInstance(failureObject, Failure)
        tracebackObject = failureObject.getTracebackObject()
        self.assertEqual(tracebackObject.tb_frame.f_code.co_filename.rstrip('co'), __file__.rstrip('co'))
    checkEvents(logged)
    checkEvents(deserialized)