summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_itertools.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-02-02 23:34:09 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-02-02 23:34:09 (GMT)
commit42aa9c078a28f54fd30bf3a9feb3176e42049ca4 (patch)
tree59d09b442591078284913109c2f70eb30696f6f2 /Lib/test/test_itertools.py
parent77a57c7570fa77ea7ccac72286369b56df8509da (diff)
downloadcpython-42aa9c078a28f54fd30bf3a9feb3176e42049ca4.zip
cpython-42aa9c078a28f54fd30bf3a9feb3176e42049ca4.tar.gz
cpython-42aa9c078a28f54fd30bf3a9feb3176e42049ca4.tar.bz2
Issues #23363, #23364, #23365, #23366: Fixed itertools overflow tests.
Used PyMem_New to check overflow.
Diffstat (limited to 'Lib/test/test_itertools.py')
-rw-r--r--Lib/test/test_itertools.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 3c7dd49..bde7ab6 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -139,7 +139,7 @@ class TestBasicOps(unittest.TestCase):
@test_support.bigaddrspacetest
def test_combinations_overflow(self):
- with self.assertRaises(OverflowError):
+ with self.assertRaises((OverflowError, MemoryError)):
combinations("AA", 2**29)
@test_support.impl_detail("tuple reuse is specific to CPython")
@@ -215,7 +215,7 @@ class TestBasicOps(unittest.TestCase):
@test_support.bigaddrspacetest
def test_combinations_with_replacement_overflow(self):
- with self.assertRaises(OverflowError):
+ with self.assertRaises((OverflowError, MemoryError)):
combinations_with_replacement("AA", 2**30)
@test_support.impl_detail("tuple reuse is specific to CPython")
@@ -286,10 +286,8 @@ class TestBasicOps(unittest.TestCase):
@test_support.bigaddrspacetest
def test_permutations_overflow(self):
- with self.assertRaises(OverflowError):
+ with self.assertRaises((OverflowError, MemoryError)):
permutations("A", 2**30)
- with self.assertRaises(OverflowError):
- permutations("A", 2, 2**30)
@test_support.impl_detail("tuple reuse is specific to CPython")
def test_permutations_tuple_reuse(self):
@@ -711,8 +709,8 @@ class TestBasicOps(unittest.TestCase):
@test_support.bigaddrspacetest
def test_product_overflow(self):
- with self.assertRaises(OverflowError):
- product(["a"]*(2**16), repeat=2**16)
+ with self.assertRaises((OverflowError, MemoryError)):
+ product(*(['ab']*2**5), repeat=2**25)
@test_support.impl_detail("tuple reuse is specific to CPython")
def test_product_tuple_reuse(self):