PY-23164 Fixed: unittest unresolved attribute reference in setUp inside with statement

Don't skip with-statement children while collecting target expressions inside function.
This commit is contained in:
Semyon Proshev
2017-03-24 14:53:55 +03:00
parent 74a1553ac3
commit d5204ab32b
3 changed files with 15 additions and 0 deletions
@@ -1222,6 +1222,8 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
.map(PyWithItem::getTarget)
.select(PyTargetExpression.class)
.forEach(result::add);
super.visitPyWithStatement(node);
}
});
return result;
@@ -0,0 +1,8 @@
class Foo(object):
def __init__(self):
with open('b.py'):
self.scope = "a"
pass
def get_scope(self):
return self.scope
@@ -758,6 +758,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
assertNotParsed((PyFile)fooPsiFile);
}
// PY-23164
public void testInstanceAttributeCreatedInsideWithStatement() {
doTest();
}
@NotNull
@Override
protected Class<? extends PyInspection> getInspectionClass() {