Пример #1
0
 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
Пример #2
0
 def test_render(self):
     cm_stub = _func_stub_from_callable(Dummy.a_class_method.__func__)
     im_stub = _func_stub_from_callable(Dummy.an_instance_method)
     class_stub = ClassStub('Test', function_stubs=(cm_stub, im_stub))
     expected = "\n".join([
         'class Test:',
         cm_stub.render(prefix='    '),
         im_stub.render(prefix='    '),
     ])
     assert class_stub.render() == expected
Пример #3
0
 def test_render(self):
     cm_stub = _func_stub_from_callable(Dummy.a_class_method.__func__)
     im_stub = _func_stub_from_callable(Dummy.an_instance_method)
     class_stub = ClassStub('Test', function_stubs=(cm_stub, im_stub),
                            attribute_stubs=[
                                AttributeStub('foo', int),
                                AttributeStub('bar', str),
                             ])
     expected = '\n'.join([
         'class Test:',
         '    bar: str',
         '    foo: int',
         '    @classmethod',
         '    def a_class_method(cls, foo: Any) -> Optional[frame]: ...',
         '    def an_instance_method(self, foo: Any, bar: Any) -> Optional[frame]: ...',
     ])
     assert class_stub.render() == expected