summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_with.py
diff options
context:
space:
mode:
authorBatuhan Taskaya <batuhanosmantaskaya@gmail.com>2020-10-09 09:56:48 (GMT)
committerGitHub <noreply@github.com>2020-10-09 09:56:48 (GMT)
commit48f305fd122080a9181cbda33bdb42ea36a0136f (patch)
tree801a6a7bd051bc6a0075d823779bf9cc24099721 /Lib/test/test_with.py
parent666f583e9e47d04c557a20555379d97e810779a6 (diff)
downloadcpython-48f305fd122080a9181cbda33bdb42ea36a0136f.zip
cpython-48f305fd122080a9181cbda33bdb42ea36a0136f.tar.gz
cpython-48f305fd122080a9181cbda33bdb42ea36a0136f.tar.bz2
bpo-41979: Accept star-unpacking on with-item targets (GH-22611)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/test/test_with.py')
-rw-r--r--Lib/test/test_with.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py
index b1d7a15..f21bf65 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -7,7 +7,7 @@ __email__ = "mbland at acm dot org"
import sys
import unittest
from collections import deque
-from contextlib import _GeneratorContextManager, contextmanager
+from contextlib import _GeneratorContextManager, contextmanager, nullcontext
class MockContextManager(_GeneratorContextManager):
@@ -641,6 +641,12 @@ class AssignmentTargetTestCase(unittest.TestCase):
self.assertEqual(blah.two, 2)
self.assertEqual(blah.three, 3)
+ def testWithExtendedTargets(self):
+ with nullcontext(range(1, 5)) as (a, *b, c):
+ self.assertEqual(a, 1)
+ self.assertEqual(b, [2, 3])
+ self.assertEqual(c, 4)
+
class ExitSwallowsExceptionTestCase(unittest.TestCase):