summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-06-14 19:08:21 (GMT)
committerGitHub <noreply@github.com>2024-06-14 19:08:21 (GMT)
commitda40fa35263893f78e75205c54fa3bcd24a64468 (patch)
tree95ff2edd5a8d581f185d3e9202f4b6ce2eea2dfd /Lib/test
parent6e3e1124287858b6e22d10ac912e9b76afa3e41b (diff)
downloadcpython-da40fa35263893f78e75205c54fa3bcd24a64468.zip
cpython-da40fa35263893f78e75205c54fa3bcd24a64468.tar.gz
cpython-da40fa35263893f78e75205c54fa3bcd24a64468.tar.bz2
[3.13] gh-120361: Add `nonmember` test with enum flags inside to `test_enum` (GH-120364) (#120511)
gh-120361: Add `nonmember` test with enum flags inside to `test_enum` (GH-120364) * gh-120361: Add `nonmember` test with enum flags inside to `test_enum` (cherry picked from commit 7fadfd82ebf6ea90b38cb3f2a046a51f8601a205) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_enum.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index 529dfc6..99fd16b 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -1495,6 +1495,27 @@ class TestSpecial(unittest.TestCase):
spam = nonmember(SpamEnumIsInner)
self.assertTrue(SpamEnum.spam is SpamEnumIsInner)
+ def test_using_members_as_nonmember(self):
+ class Example(Flag):
+ A = 1
+ B = 2
+ ALL = nonmember(A | B)
+
+ self.assertEqual(Example.A.value, 1)
+ self.assertEqual(Example.B.value, 2)
+ self.assertEqual(Example.ALL, 3)
+ self.assertIs(type(Example.ALL), int)
+
+ class Example(Flag):
+ A = auto()
+ B = auto()
+ ALL = nonmember(A | B)
+
+ self.assertEqual(Example.A.value, 1)
+ self.assertEqual(Example.B.value, 2)
+ self.assertEqual(Example.ALL, 3)
+ self.assertIs(type(Example.ALL), int)
+
def test_nested_classes_in_enum_with_member(self):
"""Support locally-defined nested classes."""
class Outer(Enum):