Esempio n. 1
0
    def test_unknown(self):
        unknown = type('Unknown', (object,), {})

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

        def foo(x: unknown):
            return x

        with self.assertRaises(TypeError):
            generate(foo)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)