summaryrefslogtreecommitdiff
path: root/tests/basics/fun_error.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-04-04 22:05:30 +0100
committerDamien George <damien.p.george@gmail.com>2015-04-04 22:05:30 +0100
commit9dd36404646f857c4f250537bac0d9a8ad041d25 (patch)
treec6509bcd3c7d5c2e67332110c582df2b5a5c669f /tests/basics/fun_error.py
parent7e758b1cf878312cab5d9d2825b36e7235ea10a3 (diff)
tests: Add missing tests for builtins, and many other things.
Diffstat (limited to 'tests/basics/fun_error.py')
-rw-r--r--tests/basics/fun_error.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/basics/fun_error.py b/tests/basics/fun_error.py
new file mode 100644
index 000000000..02af7b1bb
--- /dev/null
+++ b/tests/basics/fun_error.py
@@ -0,0 +1,31 @@
+# test errors from bad function calls
+
+def test_exc(code, exc):
+ try:
+ exec(code)
+ print("no exception")
+ except exc:
+ print("right exception")
+ except:
+ print("wrong exception")
+
+# function doesn't take keyword args
+test_exc("[].append(x=1)", TypeError)
+
+# function with variable number of positional args given too few
+test_exc("round()", TypeError)
+
+# function with variable number of positional args given too many
+test_exc("round(1, 2, 3)", TypeError)
+
+# function with fixed number of positional args given wrong number
+test_exc("[].append(1, 2)", TypeError)
+
+# function with keyword args given extra positional args
+test_exc("[].sort(1)", TypeError)
+
+# function with keyword args given extra keyword args
+test_exc("[].sort(noexist=1)", TypeError)
+
+# function with keyword args not given a specific keyword arg
+test_exc("enumerate()", TypeError)