summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-05-18 05:44:29 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-05-18 05:44:29 (GMT)
commit094c9c921cc889f1aac99bbcc26b70b19f8ef1d9 (patch)
treeb1b277a2de09a9d534a9bebc1d5b563b7dc54258 /Lib/test
parent93d22ecc7c7e2d3413bb21e0264a293f7884caee (diff)
downloadcpython-094c9c921cc889f1aac99bbcc26b70b19f8ef1d9.zip
cpython-094c9c921cc889f1aac99bbcc26b70b19f8ef1d9.tar.gz
cpython-094c9c921cc889f1aac99bbcc26b70b19f8ef1d9.tar.bz2
Issue #23275: Allow () = iterable assignment syntax
Documentation updates by Martin Panter.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_codeop.py1
-rw-r--r--Lib/test/test_syntax.py12
-rw-r--r--Lib/test/test_unpack.py21
-rw-r--r--Lib/test/test_with.py5
4 files changed, 21 insertions, 18 deletions
diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py
index 509bf5d..98da26f 100644
--- a/Lib/test/test_codeop.py
+++ b/Lib/test/test_codeop.py
@@ -282,7 +282,6 @@ class CodeopTests(unittest.TestCase):
ai("if (a == 1 and b = 2): pass")
ai("del 1")
- ai("del ()")
ai("del (1,)")
ai("del [1]")
ai("del '1'")
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 057441c..38fc417 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -35,14 +35,6 @@ SyntaxError: invalid syntax
Traceback (most recent call last):
SyntaxError: can't assign to keyword
-It's a syntax error to assign to the empty tuple. Why isn't it an
-error to assign to the empty list? It will always raise some error at
-runtime.
-
->>> () = 1
-Traceback (most recent call last):
-SyntaxError: can't assign to ()
-
>>> f() = 1
Traceback (most recent call last):
SyntaxError: can't assign to function call
@@ -491,10 +483,6 @@ Traceback (most recent call last):
...
SyntaxError: keyword argument repeated
->>> del ()
-Traceback (most recent call last):
-SyntaxError: can't delete ()
-
>>> {1, 2, 3} = 42
Traceback (most recent call last):
SyntaxError: can't assign to literal
diff --git a/Lib/test/test_unpack.py b/Lib/test/test_unpack.py
index d1ccb38..3fcb18f 100644
--- a/Lib/test/test_unpack.py
+++ b/Lib/test/test_unpack.py
@@ -117,6 +117,27 @@ error)
...
test.test_unpack.BozoError
+Allow unpacking empty iterables
+
+ >>> () = []
+ >>> [] = ()
+ >>> [] = []
+ >>> () = ()
+
+Unpacking non-iterables should raise TypeError
+
+ >>> () = 42
+ Traceback (most recent call last):
+ ...
+ TypeError: 'int' object is not iterable
+
+Unpacking to an empty iterable should raise ValueError
+
+ >>> () = [42]
+ Traceback (most recent call last):
+ ...
+ ValueError: too many values to unpack (expected 0)
+
"""
__test__ = {'doctests' : doctests}
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py
index 3815062..e247ff6 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -140,11 +140,6 @@ class FailureTestCase(unittest.TestCase):
'with mock as (None):\n'
' pass')
- def testAssignmentToEmptyTupleError(self):
- self.assertRaisesSyntaxError(
- 'with mock as ():\n'
- ' pass')
-
def testAssignmentToTupleOnlyContainingNoneError(self):
self.assertRaisesSyntaxError('with mock as None,:\n pass')
self.assertRaisesSyntaxError(