~ubuntu-branches/ubuntu/trusty/python3.4/trusty-proposed

« back to all changes in this revision

Viewing changes to Lib/test/test_call.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-11-25 09:44:27 UTC
  • Revision ID: package-import@ubuntu.com-20131125094427-lzxj8ap5w01lmo7f
Tags: upstream-3.4~b1
ImportĀ upstreamĀ versionĀ 3.4~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import unittest
 
2
from test import support
 
3
 
 
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.
 
8
 
 
9
class CFunctionCalls(unittest.TestCase):
 
10
 
 
11
    def test_varargs0(self):
 
12
        self.assertRaises(TypeError, {}.__contains__)
 
13
 
 
14
    def test_varargs1(self):
 
15
        {}.__contains__(0)
 
16
 
 
17
    def test_varargs2(self):
 
18
        self.assertRaises(TypeError, {}.__contains__, 0, 1)
 
19
 
 
20
    def test_varargs0_ext(self):
 
21
        try:
 
22
            {}.__contains__(*())
 
23
        except TypeError:
 
24
            pass
 
25
 
 
26
    def test_varargs1_ext(self):
 
27
        {}.__contains__(*(0,))
 
28
 
 
29
    def test_varargs2_ext(self):
 
30
        try:
 
31
            {}.__contains__(*(1, 2))
 
32
        except TypeError:
 
33
            pass
 
34
        else:
 
35
            raise RuntimeError
 
36
 
 
37
    def test_varargs0_kw(self):
 
38
        self.assertRaises(TypeError, {}.__contains__, x=2)
 
39
 
 
40
    def test_varargs1_kw(self):
 
41
        self.assertRaises(TypeError, {}.__contains__, x=2)
 
42
 
 
43
    def test_varargs2_kw(self):
 
44
        self.assertRaises(TypeError, {}.__contains__, x=2, y=2)
 
45
 
 
46
    def test_oldargs0_0(self):
 
47
        {}.keys()
 
48
 
 
49
    def test_oldargs0_1(self):
 
50
        self.assertRaises(TypeError, {}.keys, 0)
 
51
 
 
52
    def test_oldargs0_2(self):
 
53
        self.assertRaises(TypeError, {}.keys, 0, 1)
 
54
 
 
55
    def test_oldargs0_0_ext(self):
 
56
        {}.keys(*())
 
57
 
 
58
    def test_oldargs0_1_ext(self):
 
59
        try:
 
60
            {}.keys(*(0,))
 
61
        except TypeError:
 
62
            pass
 
63
        else:
 
64
            raise RuntimeError
 
65
 
 
66
    def test_oldargs0_2_ext(self):
 
67
        try:
 
68
            {}.keys(*(1, 2))
 
69
        except TypeError:
 
70
            pass
 
71
        else:
 
72
            raise RuntimeError
 
73
 
 
74
    def test_oldargs0_0_kw(self):
 
75
        try:
 
76
            {}.keys(x=2)
 
77
        except TypeError:
 
78
            pass
 
79
        else:
 
80
            raise RuntimeError
 
81
 
 
82
    def test_oldargs0_1_kw(self):
 
83
        self.assertRaises(TypeError, {}.keys, x=2)
 
84
 
 
85
    def test_oldargs0_2_kw(self):
 
86
        self.assertRaises(TypeError, {}.keys, x=2, y=2)
 
87
 
 
88
    def test_oldargs1_0(self):
 
89
        self.assertRaises(TypeError, [].count)
 
90
 
 
91
    def test_oldargs1_1(self):
 
92
        [].count(1)
 
93
 
 
94
    def test_oldargs1_2(self):
 
95
        self.assertRaises(TypeError, [].count, 1, 2)
 
96
 
 
97
    def test_oldargs1_0_ext(self):
 
98
        try:
 
99
            [].count(*())
 
100
        except TypeError:
 
101
            pass
 
102
        else:
 
103
            raise RuntimeError
 
104
 
 
105
    def test_oldargs1_1_ext(self):
 
106
        [].count(*(1,))
 
107
 
 
108
    def test_oldargs1_2_ext(self):
 
109
        try:
 
110
            [].count(*(1, 2))
 
111
        except TypeError:
 
112
            pass
 
113
        else:
 
114
            raise RuntimeError
 
115
 
 
116
    def test_oldargs1_0_kw(self):
 
117
        self.assertRaises(TypeError, [].count, x=2)
 
118
 
 
119
    def test_oldargs1_1_kw(self):
 
120
        self.assertRaises(TypeError, [].count, {}, x=2)
 
121
 
 
122
    def test_oldargs1_2_kw(self):
 
123
        self.assertRaises(TypeError, [].count, x=2, y=2)
 
124
 
 
125
 
 
126
def test_main():
 
127
    support.run_unittest(CFunctionCalls)
 
128
 
 
129
 
 
130
if __name__ == "__main__":
 
131
    test_main()