def test_extractField(self, flattenFirst=lambda x: x):
        """
        L{extractField} will extract a field used in the format string.

        @param flattenFirst: callable to flatten an event
        """
        class ObjectWithRepr(object):
            def __repr__(self):
                return "repr"

        class Something(object):
            def __init__(self):
                self.number = 7
                self.object = ObjectWithRepr()

            def __getstate__(self):
                raise NotImplementedError("Just in case.")

        event = dict(
            log_format="{something.number} {something.object}",
            something=Something(),
        )

        flattened = flattenFirst(event)

        def extract(field):
            return extractField(field, flattened)

        self.assertEqual(extract("something.number"), 7)
        self.assertEqual(extract("something.number!s"), "7")
        self.assertEqual(extract("something.object!s"), "repr")

        L{extractField} will extract a field used in the format string.

        @param flattenFirst: callable to flatten an event
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/logger/test/test_flatten.py