def test_new_typeof_import(self): Person = pylint_protobuf.TypeClass(object()) mod_globals = {'module_pb2.Person': Person} module_pb2 = pylint_protobuf.Module('module_pb2', mod_globals) scope = {'module_pb2': module_pb2} node = astroid.extract_node('module_pb2.Person') assert pylint_protobuf._typeof(scope, node) is Person
def test_new_typeof_call(self): Person = object() scope = {'Person': pylint_protobuf.TypeClass(Person)} node = astroid.extract_node(""" Person() """) assert pylint_protobuf._typeof(scope, node) is Person
def test_new_typeof_module_factory_import(self): Factory = object() Person = object() scope = { 'factory': Factory, 'factory.mod': pylint_protobuf.Module, 'factory.mod.Person': Person, } node = astroid.extract_node('factory.mod.Person') assert pylint_protobuf._typeof(scope, node) is Person
def test_new_slice_nested_dict(self): Person = object() scope = {'Person': Person} node = astroid.extract_node(""" { "outer": { "inner": Person } }["outer"]["inner"] """) assert pylint_protobuf._typeof(scope, node) is Person
def test_new_typeof_wacky_import(self): Person = pylint_protobuf.TypeClass(object()) Rando = pylint_protobuf.TypeClass(object()) scope = { 'mod': pylint_protobuf.Module, 'other': pylint_protobuf.Module, 'mod.child': pylint_protobuf.Module, 'mod.child.Person': Person, 'other.child': pylint_protobuf.Module, 'other.child.Person': Rando, } node = astroid.extract_node('mod.child.Person') assert pylint_protobuf._typeof(scope, node) is Person
def test_new_slice_dict(self): Person = object() scope = {'Person': Person} node = astroid.extract_node('{"a": Person}["a"]') assert pylint_protobuf._typeof(scope, node) is Person
def test_new_typeof_only(self): Person = object() scope = {'Person': Person} node = astroid.extract_node('Person') assert pylint_protobuf._typeof(scope, node) is Person