[Python-checkins] bpo-38120: Fix DeprecationWarning in test_random for invalid type of arguments to random.seed. (GH-15987)

Serhiy Storchaka webhook-mailer at python.org
Thu Sep 12 04:13:26 EDT 2019


https://github.com/python/cpython/commit/a06d683d7fd88721eaf59abcf5b02eb82045c7b1
commit: a06d683d7fd88721eaf59abcf5b02eb82045c7b1
branch: master
author: Xtreak <tir.karthi at gmail.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2019-09-12T11:13:20+03:00
summary:

bpo-38120: Fix DeprecationWarning in test_random for invalid type of arguments to random.seed. (GH-15987)

files:
M Lib/test/test_random.py

diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 899ca108c65d..f59c5652b5dd 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -41,11 +41,17 @@ 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),
-                    3.14, 1+2j, 'a', tuple('abc'), MySeed()]:
+        for arg in [None, 0, 1, -1, 10**20, -(10**20),
+                    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), [])
 



More information about the Python-checkins mailing list