summaryrefslogtreecommitdiff
path: root/Lib/test/test_py3kwarn.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-11-19 22:54:57 +0000
committerBenjamin Peterson <benjamin@python.org>2009-11-19 22:54:57 +0000
commit99a5023c80d9a690e4305e2ded1b2a9cf6b30251 (patch)
tree3fb07d09a0ba874e6607b11b1ad9cc55515c1daa /Lib/test/test_py3kwarn.py
parentb678de8ba643d940009f26d50d3f6014305f152c (diff)
downloadcpython-git-99a5023c80d9a690e4305e2ded1b2a9cf6b30251.tar.gz
improve several corner cases related with argument names in parenthesis
- Fix #7362: give a good error message for parenthesized arguments with defaults. - Add a py3k warning for any parenthesized arguments since those are not allowed in Py3. This warning is not given in tuple unpacking, since that incurs the tuple unpacking warning.
Diffstat (limited to 'Lib/test/test_py3kwarn.py')
-rw-r--r--Lib/test/test_py3kwarn.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py
index c7fdd6ba56..d754faa75e 100644
--- a/Lib/test/test_py3kwarn.py
+++ b/Lib/test/test_py3kwarn.py
@@ -30,6 +30,18 @@ class TestPy3KWarnings(unittest.TestCase):
exec "`2`" in {}
self.assertWarning(None, w, expected)
+ def test_paren_arg_names(self):
+ expected = 'parenthesized argument names are invalid in 3.x'
+ def check(s):
+ exec s in {}
+ self.assertWarning(None, w, expected)
+ with check_warnings() as w:
+ check("def f((x)): pass")
+ check("def f((((x))), (y)): pass")
+ check("def f((x), (((y))), m=32): pass")
+ # Something like def f((a, (b))): pass will raise the tuple
+ # unpacking warning.
+
def test_forbidden_names(self):
# So we don't screw up our globals
def safe_exec(expr):