def bytes(cls, excludeName=False, excludeOptions=False):
        """
        Return L{bytes} representing an encoded OPT record.

        @param excludeName: A flag that controls whether to exclude
            the name field. This allows a non-standard name to be
            prepended during the test.
        @type excludeName: L{bool}

        @param excludeOptions: A flag that controls whether to exclude
            the RDLEN field. This allows encoded variable options to be
            appended during the test.
        @type excludeOptions: L{bool}

        @return: L{bytes} representing the encoded OPT record returned
            by L{object}.
        """
        rdlen = b'\x00\x00' # RDLEN 0
        if excludeOptions:
            rdlen = b''

        return (
            b'\x00' # 0 root zone
            b'\x00\x29' # type 41
            b'\x02\x00' # udpPayloadsize 512
            b'\x03' # extendedRCODE 3
            b'\x04' # version 4
            b'\x80\x00' # DNSSEC OK 1 + Z
            ) + rdlen

        Return L{bytes} representing an encoded OPT record.

        @param excludeName: A flag that controls whether to exclude
            the name field. This allows a non-standard name to be
            prepended during the test.
        @type excludeName: L{bool}

        @param excludeOptions: A flag that controls whether to exclude
            the RDLEN field. This allows encoded variable options to be
            appended during the test.
        @type excludeOptions: L{bool}

        @return: L{bytes} representing the encoded OPT record returned
            by L{object}.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/names/test/test_dns.py