summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-07-24 06:02:53 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-07-24 06:02:53 (GMT)
commit178f0b6ddcae040c235188b49c1f6defc76588ca (patch)
tree44fdcf3d5091a66897eaba20dad10610960785b9 /Lib
parentf79dfe3f250bab3375120e4f30643abac08b652d (diff)
downloadcpython-178f0b6ddcae040c235188b49c1f6defc76588ca.zip
cpython-178f0b6ddcae040c235188b49c1f6defc76588ca.tar.gz
cpython-178f0b6ddcae040c235188b49c1f6defc76588ca.tar.bz2
Issue #24620: Random.setstate() now validates the value of state last element.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_random.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index e648045..4b5232f 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -338,6 +338,11 @@ class MersenneTwister_TestBasicOps(TestBasicOps, unittest.TestCase):
self.assertRaises(TypeError, self.gen.setstate, (2, ('a',)*625, None))
# Last element s/b an int also
self.assertRaises(TypeError, self.gen.setstate, (2, (0,)*624+('a',), None))
+ # Last element s/b between 0 and 624
+ with self.assertRaises((ValueError, OverflowError)):
+ self.gen.setstate((2, (1,)*624+(625,), None))
+ with self.assertRaises((ValueError, OverflowError)):
+ self.gen.setstate((2, (1,)*624+(-1,), None))
# Little trick to make "tuple(x % (2**32) for x in internalstate)"
# raise ValueError. I cannot think of a simple way to achieve this, so