mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
In random's test_seedargs: Make sure to include at least one seed object with a negative hash.
This commit is contained in:
parent
b9831ab63c
commit
95aeae01e2
1 changed files with 5 additions and 1 deletions
|
@ -34,8 +34,12 @@ class TestBasicOps(unittest.TestCase):
|
|||
self.assertEqual(randseq, self.randomlist(N))
|
||||
|
||||
def test_seedargs(self):
|
||||
# Seed value with a negative hash.
|
||||
class MySeed(object):
|
||||
def __hash__(self):
|
||||
return -1729
|
||||
for arg in [None, 0, 0, 1, 1, -1, -1, 10**20, -(10**20),
|
||||
3.14, 1+2j, 'a', tuple('abc')]:
|
||||
3.14, 1+2j, 'a', tuple('abc'), MySeed()]:
|
||||
self.gen.seed(arg)
|
||||
for arg in [list(range(3)), dict(one=1)]:
|
||||
self.assertRaises(TypeError, self.gen.seed, arg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue