bpo-46477: [Enum] ensure Flag subclasses have correct bitwise methods (GH-30816)

This commit is contained in:
Ethan Furman 2022-01-22 18:27:52 -08:00 committed by GitHub
parent 976dec9b3b
commit 353e3b2820
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 42 deletions

View file

@ -2496,6 +2496,13 @@ class TestSpecial(unittest.TestCase):
self.assertEqual(Some.x.value, 1)
self.assertEqual(Some.y.value, 2)
def test_custom_flag_bitwise(self):
class MyIntFlag(int, Flag):
ONE = 1
TWO = 2
FOUR = 4
self.assertTrue(isinstance(MyIntFlag.ONE | MyIntFlag.TWO, MyIntFlag), MyIntFlag.ONE | MyIntFlag.TWO)
self.assertTrue(isinstance(MyIntFlag.ONE | 2, MyIntFlag))
class TestOrder(unittest.TestCase):
"test usage of the `_order_` attribute"