def test_render(self): cm_stub = _func_stub_from_callable(Dummy.a_class_method) im_stub = _func_stub_from_callable(Dummy.an_instance_method) func_stubs = (cm_stub, im_stub) test_stub = ClassStub('Test', function_stubs=func_stubs) test2_stub = ClassStub('Test2', function_stubs=func_stubs) class_stubs = (test_stub, test2_stub) mod_stub = ModuleStub(function_stubs=func_stubs, class_stubs=class_stubs) expected = "\n\n\n".join([ cm_stub.render(), im_stub.render(), test_stub.render(), test2_stub.render(), ]) assert mod_stub.render() == expected
def test_render(self): cm_stub = _func_stub_from_callable(Dummy.a_class_method) im_stub = _func_stub_from_callable(Dummy.an_instance_method) func_stubs = (cm_stub, im_stub) test_stub = ClassStub('Test', function_stubs=func_stubs) test2_stub = ClassStub('Test2', function_stubs=func_stubs) other_class_stubs = module_stub_for_method_with_typed_dict['tests.util'].class_stubs.values() class_stubs = (*other_class_stubs, test_stub, test2_stub) typed_dict_class_stubs = module_stub_for_method_with_typed_dict['tests.util'].typed_dict_class_stubs mod_stub = ModuleStub(function_stubs=func_stubs, class_stubs=class_stubs, typed_dict_class_stubs=typed_dict_class_stubs) expected = '\n'.join([ 'class DummyAnInstanceMethodTypedDict(TypedDict):', ' c: int', '', '', 'class FooTypedDict(TypedDict):', ' a: int', ' b: str', '', '', '@classmethod', 'def a_class_method(foo: Any) -> Optional[frame]: ...', '', '', 'def an_instance_method(self, foo: Any, bar: Any) -> Optional[frame]: ...', '', '', 'class Dummy:', ' def an_instance_method(self, foo: \'FooTypedDict\', bar: int) ' + '-> \'DummyAnInstanceMethodTypedDict\': ...', '', '', 'class Test:', ' @classmethod', ' def a_class_method(foo: Any) -> Optional[frame]: ...', ' def an_instance_method(self, foo: Any, bar: Any) -> Optional[frame]: ...', '', '', 'class Test2:', ' @classmethod', ' def a_class_method(foo: Any) -> Optional[frame]: ...', ' def an_instance_method(self, foo: Any, bar: Any) -> Optional[frame]: ...', ]) assert mod_stub.render() == expected