def _recordRoundtripTest(self, record):
        """
        Assert that encoding C{record} and then decoding the resulting bytes
        creates a record which compares equal to C{record}.

        @type record: L{dns.IEncodable}
        @param record: A record instance to encode
        """
        stream = BytesIO()
        record.encode(stream)

        length = stream.tell()
        stream.seek(0, 0)
        replica = record.__class__()
        replica.decode(stream, length)
        self.assertEqual(record, replica)

        Assert that encoding C{record} and then decoding the resulting bytes
        creates a record which compares equal to C{record}.

        @type record: L{dns.IEncodable}
        @param record: A record instance to encode
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/names/test/test_dns.py