]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Deal with "in" changes for enums in python 3.12
authorBob Halley <halley@dnspython.org>
Sat, 6 May 2023 18:21:36 +0000 (11:21 -0700)
committerBob Halley <halley@dnspython.org>
Sat, 6 May 2023 18:21:36 +0000 (11:21 -0700)
In python 3.12, "in" for enums tests values as well, so something
like "12345 in dns.rdatatype.RdataType" will now return True.  This
broke some logic guarding against registering a known-but-unimplmemented
type code point with a class that didn't have the right name.  We now
just give up on this test as it will never be a real problem.  We change
a few related tests to be more sensible.

dns/rdata.py
tests/test_rdata.py

index 66c07eeca16914b3cd4a83a070cfeb7b02771b6d..f0b340c7348518ac22fd312a3eae3b7c98d376fe 100644 (file)
@@ -884,14 +884,6 @@ def register_type(
     existing_cls = get_rdata_class(rdclass, rdtype)
     if existing_cls != GenericRdata or dns.rdatatype.is_metatype(rdtype):
         raise RdatatypeExists(rdclass=rdclass, rdtype=rdtype)
-    try:
-        if (
-            rdtype in dns.rdatatype.RdataType
-            and dns.rdatatype.RdataType(rdtype).name != rdtype_text
-        ):
-            raise RdatatypeExists(rdclass=rdclass, rdtype=rdtype)
-    except ValueError:
-        pass
     _rdata_classes[(rdclass, rdtype)] = getattr(
         implementation, rdtype_text.replace("-", "_")
     )
index 73023693a74292af78196e491dca0de2bfd94561..b9cfea8edf2d071332dd84d3264a6ae32558391f 100644 (file)
@@ -586,13 +586,12 @@ class RdataTestCase(unittest.TestCase):
         rd = dns.rdata.from_text("in", "rrsig", text)
         self.assertEqual(repr(rd), "<DNS IN RRSIG(NSEC) rdata: " + text + ">")
 
-    def test_bad_registration_implementing_known_type_with_wrong_name(self):
-        # Try to register an implementation at the MG codepoint that isn't
-        # called "MG"
+    def test_registration_implementing_known_and_implemented_type(self):
+        # Try to register an implementation at the A codepoint.
         with self.assertRaises(dns.rdata.RdatatypeExists):
-            dns.rdata.register_type(None, dns.rdatatype.MG, "NOTMG")
+            dns.rdata.register_type(None, dns.rdatatype.A, "ANYTHING")
 
-    def test_registration_implementing_known_type_with_right_name(self):
+    def test_registration_of_known_but_unimplmented_type(self):
         # Try to register an implementation at the MD codepoint
         dns.rdata.register_type(tests.md_module, dns.rdatatype.MD, "MD")
         rd = dns.rdata.from_text("in", "md", "foo.")