def test_encode(self):
        """
        L{dns._OPTHeader.encode} packs the header fields and writes
        them to a file like object passed in as an argument.
        """
        b = BytesIO()

        OPTNonStandardAttributes.object().encode(b)
        self.assertEqual(
            b.getvalue(),
            OPTNonStandardAttributes.bytes()
            )

        L{dns._OPTHeader.encode} packs the header fields and writes
        them to a file like object passed in as an argument.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/names/test/test_dns.py