'L{Name.encode} encodes its name information and writes it to the
file-like object passed to it.'

def test_encode(self):

    name = dns.Name('foo.example.com')
    stream = BytesIO()
    name.encode(stream)
    self.assertEqual(stream.getvalue(), '\x03foo\x07example\x03com\x00')
