diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2020-02-10 09:33:35 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2020-02-10 09:33:35 +0100 |
commit | 78e56c64cb016e372a5ae017798ebd7cf83e1f26 (patch) | |
tree | f4b862b9e2ca5b2efd704545ddfdfb4db1635dd9 /tests/unittest_brain.py | |
parent | 7dc1d50809a9f1c6b593c41949c28896c6ee0dd7 (diff) | |
download | astroid-git-78e56c64cb016e372a5ae017798ebd7cf83e1f26.tar.gz |
Skip non ``Assign`` and ``AnnAssign`` nodes from enum reinterpretation
Closes PyCQA/pylint#3365
Diffstat (limited to 'tests/unittest_brain.py')
-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 1a082d12..11b2225d 100644 --- a/tests/unittest_brain.py +++ b/tests/unittest_brain.py @@ -622,6 +622,21 @@ class EnumBrainTest(unittest.TestCase): test = next(enumeration.igetattr("test")) self.assertEqual(test.value, 42) + def test_ignores_with_nodes_from_body_of_enum(self): + code = """ + import enum + + class Error(enum.Enum): + Foo = "foo" + Bar = "bar" + with "error" as err: + pass + """ + node = builder.extract_node(code) + inferred = next(node.infer()) + assert "err" in inferred.locals + assert len(inferred.locals["err"]) == 1 + def test_enum_multiple_base_classes(self): module = builder.parse( """ |