def test_formatFlatEventWithMutatedFields(self):
        """
        L{formatEvent} will prefer the stored C{str()} or C{repr()} value for
        an object, in case the other version.
        """
        class Unpersistable(object):
            """
            Unpersitable object.
            """
            destructed = False

            def selfDestruct(self):
                """
                Self destruct.
                """
                self.destructed = True

            def __repr__(self):
                if self.destructed:
                    return "post-serialization garbage"
                else:
                    return "un-persistable"

        up = Unpersistable()
        event1 = dict(
            log_format="unpersistable: {unpersistable}", unpersistable=up
        )

        flattenEvent(event1)
        up.selfDestruct()

        self.assertEqual(formatEvent(event1), "unpersistable: un-persistable")

        L{formatEvent} will prefer the stored C{str()} or C{repr()} value for
        an object, in case the other version.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/logger/test/test_flatten.py