1 | n/a | import unittest |
---|
2 | n/a | |
---|
3 | n/a | # The test cases here cover several paths through the function calling |
---|
4 | n/a | # code. They depend on the METH_XXX flag that is used to define a C |
---|
5 | n/a | # function, which can't be verified from Python. If the METH_XXX decl |
---|
6 | n/a | # for a C function changes, these tests may not cover the right paths. |
---|
7 | n/a | |
---|
8 | n/a | class CFunctionCalls(unittest.TestCase): |
---|
9 | n/a | |
---|
10 | n/a | def test_varargs0(self): |
---|
11 | n/a | self.assertRaises(TypeError, {}.__contains__) |
---|
12 | n/a | |
---|
13 | n/a | def test_varargs1(self): |
---|
14 | n/a | {}.__contains__(0) |
---|
15 | n/a | |
---|
16 | n/a | def test_varargs2(self): |
---|
17 | n/a | self.assertRaises(TypeError, {}.__contains__, 0, 1) |
---|
18 | n/a | |
---|
19 | n/a | def test_varargs0_ext(self): |
---|
20 | n/a | try: |
---|
21 | n/a | {}.__contains__(*()) |
---|
22 | n/a | except TypeError: |
---|
23 | n/a | pass |
---|
24 | n/a | |
---|
25 | n/a | def test_varargs1_ext(self): |
---|
26 | n/a | {}.__contains__(*(0,)) |
---|
27 | n/a | |
---|
28 | n/a | def test_varargs2_ext(self): |
---|
29 | n/a | try: |
---|
30 | n/a | {}.__contains__(*(1, 2)) |
---|
31 | n/a | except TypeError: |
---|
32 | n/a | pass |
---|
33 | n/a | else: |
---|
34 | n/a | raise RuntimeError |
---|
35 | n/a | |
---|
36 | n/a | def test_varargs0_kw(self): |
---|
37 | n/a | self.assertRaises(TypeError, {}.__contains__, x=2) |
---|
38 | n/a | |
---|
39 | n/a | def test_varargs1_kw(self): |
---|
40 | n/a | self.assertRaises(TypeError, {}.__contains__, x=2) |
---|
41 | n/a | |
---|
42 | n/a | def test_varargs2_kw(self): |
---|
43 | n/a | self.assertRaises(TypeError, {}.__contains__, x=2, y=2) |
---|
44 | n/a | |
---|
45 | n/a | def test_oldargs0_0(self): |
---|
46 | n/a | {}.keys() |
---|
47 | n/a | |
---|
48 | n/a | def test_oldargs0_1(self): |
---|
49 | n/a | self.assertRaises(TypeError, {}.keys, 0) |
---|
50 | n/a | |
---|
51 | n/a | def test_oldargs0_2(self): |
---|
52 | n/a | self.assertRaises(TypeError, {}.keys, 0, 1) |
---|
53 | n/a | |
---|
54 | n/a | def test_oldargs0_0_ext(self): |
---|
55 | n/a | {}.keys(*()) |
---|
56 | n/a | |
---|
57 | n/a | def test_oldargs0_1_ext(self): |
---|
58 | n/a | try: |
---|
59 | n/a | {}.keys(*(0,)) |
---|
60 | n/a | except TypeError: |
---|
61 | n/a | pass |
---|
62 | n/a | else: |
---|
63 | n/a | raise RuntimeError |
---|
64 | n/a | |
---|
65 | n/a | def test_oldargs0_2_ext(self): |
---|
66 | n/a | try: |
---|
67 | n/a | {}.keys(*(1, 2)) |
---|
68 | n/a | except TypeError: |
---|
69 | n/a | pass |
---|
70 | n/a | else: |
---|
71 | n/a | raise RuntimeError |
---|
72 | n/a | |
---|
73 | n/a | def test_oldargs0_0_kw(self): |
---|
74 | n/a | try: |
---|
75 | n/a | {}.keys(x=2) |
---|
76 | n/a | except TypeError: |
---|
77 | n/a | pass |
---|
78 | n/a | else: |
---|
79 | n/a | raise RuntimeError |
---|
80 | n/a | |
---|
81 | n/a | def test_oldargs0_1_kw(self): |
---|
82 | n/a | self.assertRaises(TypeError, {}.keys, x=2) |
---|
83 | n/a | |
---|
84 | n/a | def test_oldargs0_2_kw(self): |
---|
85 | n/a | self.assertRaises(TypeError, {}.keys, x=2, y=2) |
---|
86 | n/a | |
---|
87 | n/a | def test_oldargs1_0(self): |
---|
88 | n/a | self.assertRaises(TypeError, [].count) |
---|
89 | n/a | |
---|
90 | n/a | def test_oldargs1_1(self): |
---|
91 | n/a | [].count(1) |
---|
92 | n/a | |
---|
93 | n/a | def test_oldargs1_2(self): |
---|
94 | n/a | self.assertRaises(TypeError, [].count, 1, 2) |
---|
95 | n/a | |
---|
96 | n/a | def test_oldargs1_0_ext(self): |
---|
97 | n/a | try: |
---|
98 | n/a | [].count(*()) |
---|
99 | n/a | except TypeError: |
---|
100 | n/a | pass |
---|
101 | n/a | else: |
---|
102 | n/a | raise RuntimeError |
---|
103 | n/a | |
---|
104 | n/a | def test_oldargs1_1_ext(self): |
---|
105 | n/a | [].count(*(1,)) |
---|
106 | n/a | |
---|
107 | n/a | def test_oldargs1_2_ext(self): |
---|
108 | n/a | try: |
---|
109 | n/a | [].count(*(1, 2)) |
---|
110 | n/a | except TypeError: |
---|
111 | n/a | pass |
---|
112 | n/a | else: |
---|
113 | n/a | raise RuntimeError |
---|
114 | n/a | |
---|
115 | n/a | def test_oldargs1_0_kw(self): |
---|
116 | n/a | self.assertRaises(TypeError, [].count, x=2) |
---|
117 | n/a | |
---|
118 | n/a | def test_oldargs1_1_kw(self): |
---|
119 | n/a | self.assertRaises(TypeError, [].count, {}, x=2) |
---|
120 | n/a | |
---|
121 | n/a | def test_oldargs1_2_kw(self): |
---|
122 | n/a | self.assertRaises(TypeError, [].count, x=2, y=2) |
---|
123 | n/a | |
---|
124 | n/a | |
---|
125 | n/a | if __name__ == "__main__": |
---|
126 | n/a | unittest.main() |
---|