From 8e463b8355628a5794f764b3463688a056030158 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Mon, 14 Oct 2024 02:15:23 +0200 Subject: [PATCH] Tests: add values to assert messages --- test/src/tests/dns.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/src/tests/dns.py b/test/src/tests/dns.py index 9261bbb..d360650 100644 --- a/test/src/tests/dns.py +++ b/test/src/tests/dns.py @@ -44,8 +44,12 @@ 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) @@ -53,7 +57,9 @@ def test_ipv4_udp_dns_in_a(): 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" @@ -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" @@ -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"