mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
commit
5d0bb852a2
3 changed files with 32 additions and 2 deletions
|
@ -426,6 +426,13 @@ class TestBasicOps(unittest.TestCase):
|
|||
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
|
||||
self.pickletest(proto, permutations(values, r)) # test pickling
|
||||
|
||||
@support.bigaddrspacetest
|
||||
def test_permutations_overflow(self):
|
||||
with self.assertRaises(OverflowError):
|
||||
permutations("A", 2**30)
|
||||
with self.assertRaises(OverflowError):
|
||||
permutations("A", 2, 2**30)
|
||||
|
||||
@support.impl_detail("tuple reuse is specific to CPython")
|
||||
def test_permutations_tuple_reuse(self):
|
||||
self.assertEqual(len(set(map(id, permutations('abcde', 3)))), 1)
|
||||
|
@ -955,6 +962,11 @@ class TestBasicOps(unittest.TestCase):
|
|||
args = map(iter, args)
|
||||
self.assertEqual(len(list(product(*args))), expected_len)
|
||||
|
||||
@support.bigaddrspacetest
|
||||
def test_product_overflow(self):
|
||||
with self.assertRaises(OverflowError):
|
||||
product(["a"]*(2**16), repeat=2**16)
|
||||
|
||||
@support.impl_detail("tuple reuse is specific to CPython")
|
||||
def test_product_tuple_reuse(self):
|
||||
self.assertEqual(len(set(map(id, product('abc', 'def')))), 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue