ยปCore Development>Code coverage>Lib/test/test_call.py

Python code coverage for Lib/test/test_call.py

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