0001 import unittest 0002 from test import test_support 0003 0004 # The test cases here cover several paths through the function calling 0005 # code. They depend on the METH_XXX flag that is used to define a C 0006 # function, which can't be verified from Python. If the METH_XXX decl 0007 # for a C function changes, these tests may not cover the right paths. 0008 0009 class CFunctionCalls(unittest.TestCase): 0010 0011 def test_varargs0(self): 0012 self.assertRaises(TypeError, {}.has_key) 0013 0014 def test_varargs1(self): 0015 {}.has_key(0) 0016 0017 def test_varargs2(self): 0018 self.assertRaises(TypeError, {}.has_key, 0, 1) 0019 0020 def test_varargs0_ext(self): 0021 try: 0022 {}.has_key(*()) 0023 except TypeError: 0024 pass 0025 0026 def test_varargs1_ext(self): 0027 {}.has_key(*(0,)) 0028 0029 def test_varargs2_ext(self): 0030 try: 0031 {}.has_key(*(1, 2)) 0032 except TypeError: 0033 pass 0034 else: 0035 raise RuntimeError 0036 0037 def test_varargs0_kw(self): 0038 self.assertRaises(TypeError, {}.has_key, x=2) 0039 0040 def test_varargs1_kw(self): 0041 self.assertRaises(TypeError, {}.has_key, x=2) 0042 0043 def test_varargs2_kw(self): 0044 self.assertRaises(TypeError, {}.has_key, x=2, y=2) 0045 0046 def test_oldargs0_0(self): 0047 {}.keys() 0048 0049 def test_oldargs0_1(self): 0050 self.assertRaises(TypeError, {}.keys, 0) 0051 0052 def test_oldargs0_2(self): 0053 self.assertRaises(TypeError, {}.keys, 0, 1) 0054 0055 def test_oldargs0_0_ext(self): 0056 {}.keys(*()) 0057 0058 def test_oldargs0_1_ext(self): 0059 try: 0060 {}.keys(*(0,)) 0061 except TypeError: 0062 pass 0063 else: 0064 raise RuntimeError 0065 0066 def test_oldargs0_2_ext(self): 0067 try: 0068 {}.keys(*(1, 2)) 0069 except TypeError: 0070 pass 0071 else: 0072 raise RuntimeError 0073 0074 def test_oldargs0_0_kw(self): 0075 try: 0076 {}.keys(x=2) 0077 except TypeError: 0078 pass 0079 else: 0080 raise RuntimeError 0081 0082 def test_oldargs0_1_kw(self): 0083 self.assertRaises(TypeError, {}.keys, x=2) 0084 0085 def test_oldargs0_2_kw(self): 0086 self.assertRaises(TypeError, {}.keys, x=2, y=2) 0087 0088 def test_oldargs1_0(self): 0089 self.assertRaises(TypeError, [].count) 0090 0091 def test_oldargs1_1(self): 0092 [].count(1) 0093 0094 def test_oldargs1_2(self): 0095 self.assertRaises(TypeError, [].count, 1, 2) 0096 0097 def test_oldargs1_0_ext(self): 0098 try: 0099 [].count(*()) 0100 except TypeError: 0101 pass 0102 else: 0103 raise RuntimeError 0104 0105 def test_oldargs1_1_ext(self): 0106 [].count(*(1,)) 0107 0108 def test_oldargs1_2_ext(self): 0109 try: 0110 [].count(*(1, 2)) 0111 except TypeError: 0112 pass 0113 else: 0114 raise RuntimeError 0115 0116 def test_oldargs1_0_kw(self): 0117 self.assertRaises(TypeError, [].count, x=2) 0118 0119 def test_oldargs1_1_kw(self): 0120 self.assertRaises(TypeError, [].count, {}, x=2) 0121 0122 def test_oldargs1_2_kw(self): 0123 self.assertRaises(TypeError, [].count, x=2, y=2) 0124 0125 0126 def test_main(): 0127 test_support.run_unittest(CFunctionCalls) 0128 0129 0130 if __name__ == "__main__": 0131 test_main() 0132
Generated by PyXR 0.9.4