2 from test
import test_support
4 # The test cases here cover several paths through the function calling
5 # code. They depend on the METH_XXX flag that is used to define a C
6 # function, which can't be verified from Python. If the METH_XXX decl
7 # for a C function changes, these tests may not cover the right paths.
9 class CFunctionCalls(unittest
.TestCase
):
11 def test_varargs0(self
):
12 self
.assertRaises(TypeError, {}.has_key
)
14 def test_varargs1(self
):
15 with test_support
.check_py3k_warnings():
18 def test_varargs2(self
):
19 self
.assertRaises(TypeError, {}.has_key
, 0, 1)
21 def test_varargs0_ext(self
):
27 def test_varargs1_ext(self
):
28 with test_support
.check_py3k_warnings():
31 def test_varargs2_ext(self
):
33 with test_support
.check_py3k_warnings():
40 def test_varargs0_kw(self
):
41 self
.assertRaises(TypeError, {}.has_key
, x
=2)
43 def test_varargs1_kw(self
):
44 self
.assertRaises(TypeError, {}.has_key
, x
=2)
46 def test_varargs2_kw(self
):
47 self
.assertRaises(TypeError, {}.has_key
, x
=2, y
=2)
49 def test_oldargs0_0(self
):
52 def test_oldargs0_1(self
):
53 self
.assertRaises(TypeError, {}.keys
, 0)
55 def test_oldargs0_2(self
):
56 self
.assertRaises(TypeError, {}.keys
, 0, 1)
58 def test_oldargs0_0_ext(self
):
61 def test_oldargs0_1_ext(self
):
69 def test_oldargs0_2_ext(self
):
77 def test_oldargs0_0_kw(self
):
85 def test_oldargs0_1_kw(self
):
86 self
.assertRaises(TypeError, {}.keys
, x
=2)
88 def test_oldargs0_2_kw(self
):
89 self
.assertRaises(TypeError, {}.keys
, x
=2, y
=2)
91 def test_oldargs1_0(self
):
92 self
.assertRaises(TypeError, [].count
)
94 def test_oldargs1_1(self
):
97 def test_oldargs1_2(self
):
98 self
.assertRaises(TypeError, [].count
, 1, 2)
100 def test_oldargs1_0_ext(self
):
108 def test_oldargs1_1_ext(self
):
111 def test_oldargs1_2_ext(self
):
119 def test_oldargs1_0_kw(self
):
120 self
.assertRaises(TypeError, [].count
, x
=2)
122 def test_oldargs1_1_kw(self
):
123 self
.assertRaises(TypeError, [].count
, {}, x
=2)
125 def test_oldargs1_2_kw(self
):
126 self
.assertRaises(TypeError, [].count
, x
=2, y
=2)
130 test_support
.run_unittest(CFunctionCalls
)
133 if __name__
== "__main__":