summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2023-05-06 11:21:36 -0700
committerBob Halley <halley@dnspython.org>2023-05-06 11:21:36 -0700
commit83670766f84189c30450d8beed6a896bf9207fe1 (patch)
tree45d1c0d2075fdd547f8de3f5701438c2e5ede5ab
parenta2d06fe48fecad0a6b519dd45c10b364500cd83d (diff)
downloaddnspython-83670766f84189c30450d8beed6a896bf9207fe1.tar.gz
Deal with "in" changes for enums in python 3.12
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.
-rw-r--r--dns/rdata.py8
-rw-r--r--tests/test_rdata.py9
2 files changed, 4 insertions, 13 deletions
diff --git a/dns/rdata.py b/dns/rdata.py
index 66c07ee..f0b340c 100644
--- a/dns/rdata.py
+++ b/dns/rdata.py
@@ -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("-", "_")
)
diff --git a/tests/test_rdata.py b/tests/test_rdata.py
index 7302369..b9cfea8 100644
--- a/tests/test_rdata.py
+++ b/tests/test_rdata.py
@@ -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.")