def __bytes__(self): return pack('>H', self.preference) + pack_name(self.mx)
def __bytes__(self): return pack_name(self.ns)
def __bytes__(self): resource = self.resource or self.typ return (pack_name(self.name) + pack('>H', resource.value) + pack('>H', DNS_CLASS[self.cls]))
def __bytes__(self): return (pack_name(self.mname) + pack_name(self.rname) + pack('>I', self.serial) + pack('>i', self.refresh) + pack('>i', self.retry) + pack('>i', self.expire) + pack('>i', self.minimum))
def test_pack(self): self.assertEqual(pack_name('developers.apple.com'), b'\ndevelopers\x05apple\x03com\x00')
def test_empty(self): self.assertEqual(pack_name(''), b'\x00') self.assertEqual(parse_name(b'\x00', 0)[0], '')