mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-41979: Accept star-unpacking on with-item targets (GH-22611)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
parent
666f583e9e
commit
48f305fd12
4 changed files with 18 additions and 8 deletions
|
@ -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):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue