MCPcopy Index your code
hub / github.com/python/cpython / test_seedargs

Method test_seedargs

Lib/test/test_random.py:53–69  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

51 self.assertEqual(randseq, self.randomlist(N))
52
53 def test_seedargs(self):
54 # Seed value with a negative hash.
55 class MySeed(object):
56 def __hash__(self):
57 return -1729
58 for arg in [None, 0, 1, -1, 10**20, -(10**20),
59 False, True, 3.14, 'a']:
60 self.gen.seed(arg)
61
62 for arg in [1+2j, tuple('abc'), MySeed()]:
63 with self.assertRaises(TypeError):
64 self.gen.seed(arg)
65
66 for arg in [list(range(3)), dict(one=1)]:
67 self.assertRaises(TypeError, self.gen.seed, arg)
68 self.assertRaises(TypeError, self.gen.seed, 1, 2, 3, 4)
69 self.assertRaises(TypeError, type(self.gen), [])
70
71 def test_seed_no_mutate_bug_44018(self):
72 a = bytearray(b'1234')

Calls 4

MySeedClass · 0.85
listClass · 0.85
seedMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected