| 55 | self.assertEqual(p.current, len(wire)) |
| 56 | |
| 57 | def test_seek(self): |
| 58 | wire = b"\x09dnspython\x03org\x00" |
| 59 | p = dns.wire.Parser(wire) |
| 60 | p.seek(10) |
| 61 | self.assertEqual(p.get_uint8(), 3) |
| 62 | # seeking to the end index is OK |
| 63 | p.seek(len(wire)) |
| 64 | self.assertEqual(p.current, p.end) |
| 65 | with self.assertRaises(dns.exception.FormError): |
| 66 | # but reading there will not succeed |
| 67 | p.get_uint8() |
| 68 | with self.assertRaises(dns.exception.FormError): |
| 69 | p.seek(-1) |
| 70 | with self.assertRaises(dns.exception.FormError): |
| 71 | p.seek(len(wire) + 1) |
| 72 | |
| 73 | def test_not_reading_everything_in_restriction(self): |
| 74 | wire = bytes.fromhex("0102010203040102") |