MCPcopy Create free account
hub / github.com/rthalley/dnspython / test_seek

Method test_seek

tests/test_wire.py:57–71  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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")

Callers

nothing calls this directly

Calls 2

seekMethod · 0.95
get_uint8Method · 0.95

Tested by

no test coverage detected