summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-05-31 20:24:20 (GMT)
committerGitHub <noreply@github.com>2021-05-31 20:24:20 (GMT)
commita6a20658814e8668966fc86de0e80a4772864781 (patch)
treea3dd1e6bf04fd70ec20fe5829605f248e450bb86 /Lib/test
parent78d9a9b1904f0e1d9db1e941c19782f4f5a881d4 (diff)
downloadcpython-a6a20658814e8668966fc86de0e80a4772864781.zip
cpython-a6a20658814e8668966fc86de0e80a4772864781.tar.gz
cpython-a6a20658814e8668966fc86de0e80a4772864781.tar.bz2
bpo-44260: Do not read system entropy without need in Random() (GH-26455)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_random.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index c2dd50b..448624b 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -374,23 +374,6 @@ class TestBasicOps:
restoredseq = [newgen.random() for i in range(10)]
self.assertEqual(origseq, restoredseq)
- @test.support.cpython_only
- def test_bug_41052(self):
- # _random.Random should not be allowed to serialization
- import _random
- for proto in range(pickle.HIGHEST_PROTOCOL + 1):
- r = _random.Random()
- self.assertRaises(TypeError, pickle.dumps, r, proto)
-
- @test.support.cpython_only
- def test_bug_42008(self):
- # _random.Random should call seed with first element of arg tuple
- import _random
- r1 = _random.Random()
- r1.seed(8675309)
- r2 = _random.Random(8675309)
- self.assertEqual(r1.random(), r2.random())
-
def test_bug_1727780(self):
# verify that version-2-pickles can be loaded
# fine, whether they are created on 32-bit or 64-bit
@@ -573,6 +556,25 @@ class SystemRandom_TestBasicOps(TestBasicOps, unittest.TestCase):
self.assertTrue(2**k > n > 2**(k-1)) # note the stronger assertion
+class TestRawMersenneTwister(unittest.TestCase):
+ @test.support.cpython_only
+ def test_bug_41052(self):
+ # _random.Random should not be allowed to serialization
+ import _random
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ r = _random.Random()
+ self.assertRaises(TypeError, pickle.dumps, r, proto)
+
+ @test.support.cpython_only
+ def test_bug_42008(self):
+ # _random.Random should call seed with first element of arg tuple
+ import _random
+ r1 = _random.Random()
+ r1.seed(8675309)
+ r2 = _random.Random(8675309)
+ self.assertEqual(r1.random(), r2.random())
+
+
class MersenneTwister_TestBasicOps(TestBasicOps, unittest.TestCase):
gen = random.Random()