diff options
author | Joshua Cannon <joshua.cannon@ni.com> | 2021-10-21 15:19:49 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-21 22:19:49 +0200 |
commit | 7d668becd784f935ffa12b21bc457efa96e3981c (patch) | |
tree | a1a1b1be4faaaf5d0cf7b39eb487937ce310d26d | |
parent | d3ba6882e1e8d4257dac02f7e259552f8dd96037 (diff) | |
download | astroid-7d668becd784f935ffa12b21bc457efa96e3981c.tar.gz |
Add test for __members__ (#1216)
Adding a new test which ensures the local __members__ defined on an enum class isn't used for __members__ afterwards. This matches the behavior of Python.
-rw-r--r-- | tests/unittest_brain.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py index 9e8b4126..861369f3 100644 --- a/tests/unittest_brain.py +++ b/tests/unittest_brain.py @@ -1172,6 +1172,21 @@ class EnumBrainTest(unittest.TestCase): self.assertIsInstance(inferred[0], astroid.Const) self.assertEqual(inferred[0].value, 1) + def test_members_member_ignored(self) -> None: + ast_node = builder.extract_node( + """ + from enum import Enum + class Animal(Enum): + a = 1 + __members__ = {} + Animal.__members__ #@ + """ + ) + + inferred = next(ast_node.infer()) + self.assertIsInstance(inferred, astroid.Dict) + self.assertTrue(inferred.locals) + @unittest.skipUnless(HAS_DATEUTIL, "This test requires the dateutil library.") class DateutilBrainTest(unittest.TestCase): |