Skip to content

Commit a52e91b

Browse files
committed
test: cover the display compat shims
1 parent 30bc14f commit a52e91b

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎tests/test_dns.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ def teardown_module():
3030
log.setLevel(original_logging_level)
3131

3232

33+
def test_display_compat_shims():
34+
"""The legacy display helpers stay callable and route through the new formatter."""
35+
record = r.DNSPointer(
36+
"_http._tcp.local.", const._TYPE_PTR, const._CLASS_IN, const._DNS_OTHER_TTL, "demo._http._tcp.local."
37+
)
38+
assert r.DNSEntry.get_type(const._TYPE_PTR) == "ptr"
39+
assert r.DNSEntry.get_type(4242) == "unknown-type-4242"
40+
assert r.DNSEntry.get_class_(const._CLASS_IN) == "in"
41+
assert r.DNSEntry.get_class_(4242) == "unknown-class-4242"
42+
assert record.entry_to_string("hdr", None).startswith("<hdr ")
43+
assert "data=extra" in record.entry_to_string("hdr", "extra")
44+
assert "data=payload" in record.to_string("payload")
45+
assert record.type_label == "ptr"
46+
assert record.class_label == "in"
47+
48+
3349
class TestDunder(unittest.TestCase):
3450
def test_dns_text_repr(self):
3551
# There was an issue on Python 3 that prevented DNSText's repr

0 commit comments

Comments
 (0)