Skip to content

Commit 8fb5396

Browse files
authored
Merge pull request #4676 from dalinaum/test_unpack
Update test/test_unpack.py from CPython 3.11.2
2 parents ea665cb + eb7daf1 commit 8fb5396

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

Lib/test/test_unpack.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import doctest
2+
import unittest
3+
4+
15
doctests = """
26
37
Unpack tuple
@@ -142,10 +146,26 @@
142146

143147
__test__ = {'doctests' : doctests}
144148

145-
def test_main(verbose=False):
146-
from test import support
147-
from test import test_unpack
148-
support.run_doctest(test_unpack, verbose)
149+
def load_tests(loader, tests, pattern):
150+
tests.addTest(doctest.DocTestSuite())
151+
return tests
152+
153+
154+
class TestCornerCases(unittest.TestCase):
155+
def test_extended_oparg_not_ignored(self):
156+
# https://github.com/python/cpython/issues/91625
157+
target = "(" + "y,"*400 + ")"
158+
code = f"""def unpack_400(x):
159+
{target} = x
160+
return y
161+
"""
162+
ns = {}
163+
exec(code, ns)
164+
unpack_400 = ns["unpack_400"]
165+
# Warm up the the function for quickening (PEP 659)
166+
for _ in range(30):
167+
y = unpack_400(range(400))
168+
self.assertEqual(y, 399)
149169

150170
if __name__ == "__main__":
151-
test_main(verbose=True)
171+
unittest.main()

0 commit comments

Comments
 (0)