From 0602d6a0dcca0057fcfc468a2646d86081280422 Mon Sep 17 00:00:00 2001 From: Xtreak Date: Wed, 11 Sep 2019 17:08:19 +0100 Subject: [PATCH 1/2] Assert for DeprecationWarning in test_random for invalid seed arguments to random.seed --- Lib/test/test_random.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index 899ca108c65d98..c66aff8f18b245 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -42,10 +42,16 @@ 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'), MySeed()]: + 3.14, 'a']: self.gen.seed(arg) + + for arg in [1+2j, tuple('abc'), MySeed()]: + with self.assertWarns(DeprecationWarning): + self.gen.seed(arg) + for arg in [list(range(3)), dict(one=1)]: - self.assertRaises(TypeError, self.gen.seed, arg) + with self.assertWarns(DeprecationWarning): + self.assertRaises(TypeError, self.gen.seed, arg) self.assertRaises(TypeError, self.gen.seed, 1, 2, 3, 4) self.assertRaises(TypeError, type(self.gen), []) From 4f676c04f6a05af37e92559ca60f65649d616d0b Mon Sep 17 00:00:00 2001 From: Xtreak Date: Wed, 11 Sep 2019 19:17:13 +0100 Subject: [PATCH 2/2] Update Lib/test/test_random.py Co-Authored-By: Serhiy Storchaka --- Lib/test/test_random.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index c66aff8f18b245..f59c5652b5ddaa 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -41,7 +41,7 @@ def test_seedargs(self): class MySeed(object): def __hash__(self): return -1729 - for arg in [None, 0, 0, 1, 1, -1, -1, 10**20, -(10**20), + for arg in [None, 0, 1, -1, 10**20, -(10**20), 3.14, 'a']: self.gen.seed(arg)