This commit is contained in:
Benjamin Peterson 2015-02-01 21:36:01 -05:00
commit 5d0bb852a2
3 changed files with 32 additions and 2 deletions

View file

@ -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)