Example #1
0
    def test_get_method_annotation_var_kw(self):
        def meth(obj, x: int, *args, **kwargs):
            pass

        schema = Schema()
        schema.instance_method('hello')(meth)
        instance_method = schema.hello

        expected = 'def hello(self, x: int, *args, **kwargs): ...'
        assert get_method_annotation('hello', instance_method) == expected
Example #2
0
    def test_get_method_annotation_kwonly_varargs(self):
        def meth(obj, x: int, y: 'asdf' = None, *args, z=None, **kwargs) -> int:
            pass

        schema = Schema()
        schema.instance_method('hello')(meth)
        instance_method = schema.hello

        expected = 'def hello(self, x: int, y: asdf, *args, z: typing.Any, **kwargs) -> int: ...'
        assert get_method_annotation('hello', instance_method) == expected