Skip to content

Commit a06d683

Browse files
tirkarthiserhiy-storchaka
authored andcommitted
bpo-38120: Fix DeprecationWarning in test_random for invalid type of arguments to random.seed. (GH-15987)
1 parent 891e9e3 commit a06d683

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Lib/test/test_random.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,17 @@ def test_seedargs(self):
4141
class MySeed(object):
4242
def __hash__(self):
4343
return -1729
44-
for arg in [None, 0, 0, 1, 1, -1, -1, 10**20, -(10**20),
45-
3.14, 1+2j, 'a', tuple('abc'), MySeed()]:
44+
for arg in [None, 0, 1, -1, 10**20, -(10**20),
45+
3.14, 'a']:
4646
self.gen.seed(arg)
47+
48+
for arg in [1+2j, tuple('abc'), MySeed()]:
49+
with self.assertWarns(DeprecationWarning):
50+
self.gen.seed(arg)
51+
4752
for arg in [list(range(3)), dict(one=1)]:
48-
self.assertRaises(TypeError, self.gen.seed, arg)
53+
with self.assertWarns(DeprecationWarning):
54+
self.assertRaises(TypeError, self.gen.seed, arg)
4955
self.assertRaises(TypeError, self.gen.seed, 1, 2, 3, 4)
5056
self.assertRaises(TypeError, type(self.gen), [])
5157

0 commit comments

Comments
 (0)