def test_toStrCallsToMessageToStr(self):
        """
        L{dns._EDNSMessage.toStr} calls C{toStr} on the message returned by
        L{dns._EDNSMessage._toMessage}.
        """
        m = dns._EDNSMessage()
        dummyBytes = object()
        class FakeMessage(object):
            """
            Fake Message
            """
            def toStr(self):
                """
                Fake toStr which returns dummyBytes.

                @return: dummyBytes
                """
                return dummyBytes

        def fakeToMessage(*args, **kwargs):
            return FakeMessage()
        m._toMessage = fakeToMessage

        self.assertEqual(
            dummyBytes,
            m.toStr()
        )

        L{dns._EDNSMessage.toStr} calls C{toStr} on the message returned by
        L{dns._EDNSMessage._toMessage}.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/names/test/test_dns.py