Skip to content

Commit

Permalink
Tests: add values to assert messages
Browse files Browse the repository at this point in the history
  • Loading branch information
p-l- committed Oct 14, 2024
1 parent 4889429 commit 7371881
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions test/src/tests/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,22 @@ def test_ipv4_udp_dns_in_a():
check_ip_checksum(resp)
assert UDP in resp, "no UDP layer found"
udp = resp[UDP]
assert udp.sport == dport, "unexpected UDP sport: {}".format(udp.sport)
assert udp.dport == sport, "unexpected UDP dport: {}".format(udp.dport)
assert (
udp.sport == dport
), f"unexpected UDP sport: {udp.sport!r} ({domain})"
assert (
udp.dport == sport
), f"unexpected UDP dport: {udp.dport!r} ({domain})"
if DNS not in udp:
try:
dns_rep = DNS(udp.load)
except Exception:
raise AssertionError("no DNS layer found")
else:
dns_rep = udp[DNS]
assert dns_rep.id == 1234, f"unexpected id value: {dns_rep.id}"
assert (
dns_rep.id == 1234
), f"unexpected id value: {dns_rep.id!r} ({domain})"
assert dns_rep.qr, "unexpected qr value"
assert dns_rep.opcode == 0, "unexpected opcode value"
assert dns_rep.aa, "unexpected aa value"
Expand All @@ -62,7 +68,9 @@ def test_ipv4_udp_dns_in_a():
assert not dns_rep.ra, "unexpected ra value"
assert dns_rep.z == 0, "unexpected z value"
assert dns_rep.rcode == 0, "unexpected rcode value"
assert dns_rep.qdcount == 1, "unexpected qdcount value"
assert (
dns_rep.qdcount == 1
), f"unexpected qdcount value: {dns_rep.qdcount!r} vs 1 ({domain})"
assert dns_rep.ancount == 1, "unexpected ancount value"
assert dns_rep.nscount == 0, "unexpected nscount value"
assert dns_rep.arcount == 0, "unexpected arcount value"
Expand Down Expand Up @@ -125,7 +133,9 @@ def test_ipv4_udp_dns_in_a_multiple_queries():
assert not dns_rep.ra, "unexpected ra value"
assert dns_rep.z == 0, "unexpected z value"
assert dns_rep.rcode == 0, "unexpected rcode value"
assert dns_rep.qdcount == 3, "unexpected qdcount value"
assert (
dns_rep.qdcount == 3
), f"unexpected qdcount value: {dns_rep.qdcount} vs 3"
assert dns_rep.ancount == 3, "unexpected ancount value"
assert dns_rep.nscount == 0, "unexpected nscount value"
assert dns_rep.arcount == 0, "unexpected arcount value"
Expand Down

0 comments on commit 7371881

Please sign in to comment.