def test_new_assign(self): Person = object() scope = {'Person': Person} assign = astroid.extract_node("a = Person") scope, _ = pylint_protobuf.visit_assign_node(scope, {}, assign) assert 'a' in scope assert scope['a'] is Person
def test_new_assignattr(self): Person = pylint_protobuf.ClassDef({}, '') scope = {'a': Person} assign = astroid.extract_node("a.should_warn = 123") _, messages = pylint_protobuf.visit_assign_node(scope, assign) assert len(messages) == 1 msg, _, node = messages[0] assert msg == 'protobuf-undefined-attribute' assert node == assign.targets[0]
def test_new_assignattr(self): Person = object() type_fields = {Person: ['foo', 'bar']} scope = {'a': Person} assign = astroid.extract_node("a.should_warn = 123") _, messages = pylint_protobuf.visit_assign_node( scope, type_fields, assign) assert len(messages) == 1 msg, _, node = messages[0] assert msg == 'protobuf-undefined-attribute' assert node == assign.targets[0]