summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-05-29 16:26:20 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-05-29 16:26:20 (GMT)
commitbea3947fb8426bf3af423fdc7b9e2f4006b2d796 (patch)
treec2438955bda7b4b8a0fbb14088e5e09047025c19 /Lib
parent4c9dace392c537c40c2721141aab98f5799aa38b (diff)
downloadcpython-bea3947fb8426bf3af423fdc7b9e2f4006b2d796.zip
cpython-bea3947fb8426bf3af423fdc7b9e2f4006b2d796.tar.gz
cpython-bea3947fb8426bf3af423fdc7b9e2f4006b2d796.tar.bz2
Variety of test cases for call to builtin functions
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/output/test_call1
-rw-r--r--Lib/test/test_call.py125
2 files changed, 126 insertions, 0 deletions
diff --git a/Lib/test/output/test_call b/Lib/test/output/test_call
new file mode 100644
index 0000000..da00c27
--- /dev/null
+++ b/Lib/test/output/test_call
@@ -0,0 +1 @@
+test_call
diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py
new file mode 100644
index 0000000..529f15b
--- /dev/null
+++ b/Lib/test/test_call.py
@@ -0,0 +1,125 @@
+import unittest
+from test_support import run_unittest
+
+# The test cases here cover several paths through the function calling
+# code. They depend on the METH_XXX flag that is used to define a C
+# function, which can't be verified from Python. If the METH_XXX decl
+# for a C function changes, these tests may not cover the right paths.
+
+class CFunctionCalls(unittest.TestCase):
+
+ def test_varargs0(self):
+ self.assertRaises(TypeError, {}.has_key)
+
+ def test_varargs1(self):
+ {}.has_key(0)
+
+ def test_varargs2(self):
+ self.assertRaises(TypeError, {}.has_key, 0, 1)
+
+ def test_varargs0_ext(self):
+ try:
+ {}.has_key(*())
+ except TypeError:
+ pass
+
+ def test_varargs1_ext(self):
+ {}.has_key(*(0,))
+
+ def test_varargs2_ext(self):
+ try:
+ {}.has_key(*(1, 2))
+ except TypeError:
+ pass
+ else:
+ raise RuntimeError
+
+ def test_varargs0_kw(self):
+ self.assertRaises(TypeError, {}.has_key, x=2)
+
+ def test_varargs1_kw(self):
+ self.assertRaises(TypeError, {}.has_key, x=2)
+
+ def test_varargs2_kw(self):
+ self.assertRaises(TypeError, {}.has_key, x=2, y=2)
+
+ def test_oldargs0_0(self):
+ {}.keys()
+
+ def test_oldargs0_1(self):
+ self.assertRaises(TypeError, {}.keys, 0)
+
+ def test_oldargs0_2(self):
+ self.assertRaises(TypeError, {}.keys, 0, 1)
+
+ def test_oldargs0_0_ext(self):
+ {}.keys(*())
+
+ def test_oldargs0_1_ext(self):
+ try:
+ {}.keys(*(0,))
+ except TypeError:
+ pass
+ else:
+ raise RuntimeError
+
+ def test_oldargs0_2_ext(self):
+ try:
+ {}.keys(*(1, 2))
+ except TypeError:
+ pass
+ else:
+ raise RuntimeError
+
+ def test_oldargs0_0_kw(self):
+ try:
+ {}.keys(x=2)
+ except TypeError:
+ pass
+ else:
+ raise RuntimeError
+
+ def test_oldargs0_1_kw(self):
+ self.assertRaises(TypeError, {}.keys, x=2)
+
+ def test_oldargs0_2_kw(self):
+ self.assertRaises(TypeError, {}.keys, x=2, y=2)
+
+ def test_oldargs1_0(self):
+ self.assertRaises(TypeError, {}.update)
+
+ def test_oldargs1_1(self):
+ {}.update({})
+
+ def test_oldargs1_2(self):
+ self.assertRaises(TypeError, {}.update, {}, 1)
+
+ def test_oldargs1_0_ext(self):
+ try:
+ {}.update(*())
+ except TypeError:
+ pass
+ else:
+ raise RuntimeError
+
+ def test_oldargs1_1_ext(self):
+ {}.update(*({},))
+
+ def test_oldargs1_2_ext(self):
+ try:
+ {}.update(*({}, 2))
+ except TypeError:
+ pass
+ else:
+ raise RuntimeError
+
+ def test_oldargs1_0_kw(self):
+ self.assertRaises(TypeError, {}.update, x=2)
+
+ def test_oldargs1_1_kw(self):
+ self.assertRaises(TypeError, {}.update, {}, x=2)
+
+ def test_oldargs1_2_kw(self):
+ self.assertRaises(TypeError, {}.update, x=2, y=2)
+
+run_unittest(CFunctionCalls)