示例#1
0
    def test_unknown(self):
        unknown = type('Unknown', (object,), {})

        def foo(x: unknown):
            return x
        with self.assertRaises(TypeError):
            generate(foo)
示例#2
0
    def test_unknown(self):
        unknown = type("Unknown", (object, ), {})

        def foo(x: unknown):
            return x

        with self.assertRaises(TypeError):
            generate(foo)
示例#3
0
    def test_generate_map(self):
        def foo(x: {str: int}):
            return x

        fn, kw = generate(foo)
        self.assertIsInstance(kw["x"], dict)
        self.assertIs(fn, foo)
示例#4
0
    def test_generate_tuple(self):
        def foo(x: (int, float, bool)):
            return x

        fn, kw = generate(foo)
        self.assertIsInstance(kw["x"], tuple)
        self.assertIs(fn, foo)
示例#5
0
    def test_generate_set(self):
        def foo(x: set([int])):
            return x

        fn, kw = generate(foo)
        self.assertIsInstance(kw["x"], set)
        self.assertIs(fn, foo)
示例#6
0
    def test_generate_map(self):

        def foo(x: {str: int}):
            return x

        fn, kw = generate(foo)
        self.assertIsInstance(kw['x'], dict)
        self.assertIs(fn, foo)
示例#7
0
    def test_generate_tuple(self):

        def foo(x: (int, float, bool)):
            return x

        fn, kw = generate(foo)
        self.assertIsInstance(kw['x'], tuple)
        self.assertIs(fn, foo)
示例#8
0
    def test_generate_set(self):

        def foo(x: set([int])):
            return x

        fn, kw = generate(foo)
        self.assertIsInstance(kw['x'], set)
        self.assertIs(fn, foo)
示例#9
0
    def test_generate_map_nested_gen(self):
        def int_gen(a: A):
            return 1

        def foo(x: {int_gen: str}):
            return x

        fn, kw = generate(foo)
        self.assertIsInstance(kw["x"], dict)
        self.assertIs(fn, foo)
        self.assertIsInstance(kw["x"], str, kw)
示例#10
0
    def test_generate_map_nested_gen(self):

        def int_gen(a: A):
            return 1

        def foo(x: {int_gen: str}):
            return x

        fn, kw = generate(foo)
        self.assertIsInstance(kw['x'], dict)
        self.assertIs(fn, foo)
        self.assertIsInstance(kw['x'], str, kw)