summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_random.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_random.py')
-rw-r--r--Lib/test/test_random.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 90d334a..d2a4f21 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -307,6 +307,22 @@ class SystemRandom_TestBasicOps(TestBasicOps):
class MersenneTwister_TestBasicOps(TestBasicOps):
gen = random.Random()
+ @test_support.cpython_only
+ def test_bug_31478(self):
+ # _random.Random.seed() should ignore the __abs__() method of a
+ # long/int subclass argument.
+ class BadInt(int):
+ def __abs__(self):
+ 1/0
+ class BadLong(long):
+ def __abs__(self):
+ 1/0
+ self.gen.seed(42)
+ expected_value = self.gen.random()
+ for seed_arg in [42L, BadInt(42), BadLong(42)]:
+ self.gen.seed(seed_arg)
+ self.assertEqual(self.gen.random(), expected_value)
+
def test_setstate_first_arg(self):
self.assertRaises(ValueError, self.gen.setstate, (1, None, None))