From 4d4c592e2b25a48d4412b411613ceeb054962f7a Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Tue, 27 Nov 2018 15:52:11 +0100 Subject: [PATCH] fix rrset sorting --- regression-tests.auth-py/authtests.py | 7 +++++++ regression-tests.auth-py/test_LuaRecords.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/regression-tests.auth-py/authtests.py b/regression-tests.auth-py/authtests.py index c680a82dc3..61073234e1 100644 --- a/regression-tests.auth-py/authtests.py +++ b/regression-tests.auth-py/authtests.py @@ -413,6 +413,13 @@ distributor-threads=1""".format(confdir=confdir, prefix=cls._PREFIX, if not found : raise AssertionError("RRset not found in answer\n\n%s" % ret) + def sortRRsets(self, rrsets): + """Sorts RRsets in a more useful way than dnspython's default behaviour + + @param rrsets: an array of dns.rrset.RRset objects""" + + return sorted(rrsets, key=lambda rrset: (rrset.name, rrset.rdtype)) + def assertAnyRRsetInAnswer(self, msg, rrsets): """Asserts that any of the supplied rrsets exists (without comparing TTL) in the answer section of msg diff --git a/regression-tests.auth-py/test_LuaRecords.py b/regression-tests.auth-py/test_LuaRecords.py index 1a5e41aa95..693ae879c4 100644 --- a/regression-tests.auth-py/test_LuaRecords.py +++ b/regression-tests.auth-py/test_LuaRecords.py @@ -559,7 +559,7 @@ any IN TXT "hello there" res = self.sendUDPQuery(query) self.assertRcodeEqual(res, dns.rcode.NOERROR) - self.assertEqual(sorted(res.answer), sorted(response.answer)) + self.assertEqual(self.sortRRsets(res.answer), self.sortRRsets(response.answer)) if __name__ == '__main__': unittest.main() -- 2.47.2