def test_encodeWithOptions(self):
        """
        L{dns._OPTHeader.options} is a list of L{dns._OPTVariableOption}
        instances which are packed into the rdata area of the header.
        """
        h = OPTNonStandardAttributes.object()
        h.options = [
            dns._OPTVariableOption(1, b'foobarbaz'),
            dns._OPTVariableOption(2, b'qux'),
            ]
        b = BytesIO()

        h.encode(b)
        self.assertEqual(
            b.getvalue(),

            OPTNonStandardAttributes.bytes(excludeOptions=True) + (
                b'\x00\x14' # RDLEN 20

                b'\x00\x01' # OPTION-CODE
                b'\x00\x09' # OPTION-LENGTH
                b'foobarbaz' # OPTION-DATA

                b'\x00\x02' # OPTION-CODE
                b'\x00\x03' # OPTION-LENGTH
                b'qux' # OPTION-DATA
                ))

        L{dns._OPTHeader.options} is a list of L{dns._OPTVariableOption}
        instances which are packed into the rdata area of the header.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/names/test/test_dns.py