summaryrefslogtreecommitdiffstats
path: root/Lib
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)
commitdee948b359c3a68ab4d6b81319eb2f3548b64c91 (patch)
treebf05ca6298b33151de19da538137390916ade104 /Lib
parent1572944499aa7d399460076bc7872ba9d5324932 (diff)
downloadcpython-dee948b359c3a68ab4d6b81319eb2f3548b64c91.zip
cpython-dee948b359c3a68ab4d6b81319eb2f3548b64c91.tar.gz
cpython-dee948b359c3a68ab4d6b81319eb2f3548b64c91.tar.bz2
Issues #23363, #23364, #23365, #23366: Fixed itertools overflow tests.
Used PyMem_New to check overflow.
Diffstat (limited to 'Lib')
-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 3d02914..bb3b61f 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -260,7 +260,7 @@ class TestBasicOps(unittest.TestCase):
@support.bigaddrspacetest
def test_combinations_overflow(self):
- with self.assertRaises(OverflowError):
+ with self.assertRaises((OverflowError, MemoryError)):
combinations("AA", 2**29)
# Test implementation detail: tuple re-use
@@ -346,7 +346,7 @@ class TestBasicOps(unittest.TestCase):
@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 implementation detail: tuple re-use
@@ -420,10 +420,8 @@ class TestBasicOps(unittest.TestCase):
@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)
@support.impl_detail("tuple resuse is CPython specific")
def test_permutations_tuple_reuse(self):
@@ -939,8 +937,8 @@ class TestBasicOps(unittest.TestCase):
@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)
@support.impl_detail("tuple reuse is specific to CPython")
def test_product_tuple_reuse(self):