mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
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__
This commit is contained in:
parent
73ee5a6b86
commit
4e704d7847
5 changed files with 61 additions and 68 deletions
|
@ -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):
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue