def test_encode(self):
        """
        L{Name.encode} encodes its name information and writes it to the
        file-like object passed to it.
        """
        name = dns.Name(b"foo.example.com")
        stream = BytesIO()
        name.encode(stream)
        self.assertEqual(stream.getvalue(), b"\x03foo\x07example\x03com\x00")

        L{Name.encode} encodes its name information and writes it to the
        file-like object passed to it.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/names/test/test_dns.py