def test_observeWrites(self):
        """
        L{FileLogObserver} writes to the given file when it observes events.
        """
        with StringIO() as fileHandle:
            observer = FileLogObserver(fileHandle, lambda e: unicode(e))
            event = dict(x=1)
            observer(event)
            self.assertEqual(fileHandle.getvalue(), unicode(event))

        L{FileLogObserver} writes to the given file when it observes events.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/logger/test/test_file.py