summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_enum.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2022-07-25 18:05:10 (GMT)
committerGitHub <noreply@github.com>2022-07-25 18:05:10 (GMT)
commit4e704d7847f2333f581f87e31b42e44a471df93a (patch)
tree246f0b4061cdb9130f67dabda15d17aec7cff02d /Lib/test/test_enum.py
parent73ee5a6b865fbd2e89b5b1f0a33bd7bcc7176c21 (diff)
downloadcpython-4e704d7847f2333f581f87e31b42e44a471df93a.zip
cpython-4e704d7847f2333f581f87e31b42e44a471df93a.tar.gz
cpython-4e704d7847f2333f581f87e31b42e44a471df93a.tar.bz2
gh-95077: [Enum] add code-based deprecation warnings for member.member access (GH-95083)
* issue deprecation warning for member.member access * always store member property in current class * remove __getattr__
Diffstat (limited to 'Lib/test/test_enum.py')
-rw-r--r--Lib/test/test_enum.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index bfab0bd..9d16fbc 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -2646,7 +2646,10 @@ class TestSpecial(unittest.TestCase):
self.assertEqual(Private._Private__corporal, 'Radar')
self.assertEqual(Private._Private__major_, 'Hoolihan')
- @unittest.skip("Accessing all values retained for performance reasons, see GH-93910")
+ @unittest.skipIf(
+ python_version <= (3, 13),
+ 'member.member access currently deprecated',
+ )
def test_exception_for_member_from_member_access(self):
with self.assertRaisesRegex(AttributeError, "<enum .Di.> member has no attribute .NO."):
class Di(Enum):
@@ -2654,6 +2657,17 @@ class TestSpecial(unittest.TestCase):
NO = 0
nope = Di.YES.NO
+ @unittest.skipIf(
+ python_version > (3, 13),
+ 'member.member access now raises',
+ )
+ def test_warning_for_member_from_member_access(self):
+ with self.assertWarnsRegex(DeprecationWarning, '`member.member` access .* is deprecated and will be removed in 3.14'):
+ class Di(Enum):
+ YES = 1
+ NO = 0
+ warn = Di.YES.NO
+ self.assertIs(warn, Di.NO)
def test_dynamic_members_with_static_methods(self):
#