From: Bob Halley Date: Tue, 1 Sep 2020 13:38:18 +0000 (-0700) Subject: more test coverage for dns.query._matches_destination() X-Git-Tag: v2.1.0rc1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f333e7f11646b22f6ca0a4964dcf485e587a9388;p=thirdparty%2Fdnspython.git more test coverage for dns.query._matches_destination() --- diff --git a/tests/test_query.py b/tests/test_query.py index a13833ef..7a1ec718 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -540,3 +540,32 @@ class LowLevelWaitTests(unittest.TestCase): finally: l.close() r.close() + + +class MiscTests(unittest.TestCase): + def test_matches_destination(self): + self.assertTrue(dns.query._matches_destination(socket.AF_INET, + ('10.0.0.1', 1234), + ('10.0.0.1', 1234), + True)) + self.assertTrue(dns.query._matches_destination(socket.AF_INET6, + ('1::2', 1234), + ('0001::2', 1234), + True)) + self.assertTrue(dns.query._matches_destination(socket.AF_INET, + ('10.0.0.1', 1234), + None, + True)) + self.assertFalse(dns.query._matches_destination(socket.AF_INET, + ('10.0.0.1', 1234), + ('10.0.0.2', 1234), + True)) + self.assertFalse(dns.query._matches_destination(socket.AF_INET, + ('10.0.0.1', 1234), + ('10.0.0.1', 1235), + True)) + with self.assertRaises(dns.query.UnexpectedSource): + dns.query._matches_destination(socket.AF_INET, + ('10.0.0.1', 1234), + ('10.0.0.1', 1235), + False)