[Python-checkins] bpo-44785: Silence deprecation warnings in test_pickle (GH-27538) (#27557)

ambv webhook-mailer at python.org
Mon Aug 2 12:39:33 EDT 2021


https://github.com/python/cpython/commit/4817c1439519081d7bd9b396bb18b0f4124613be
commit: 4817c1439519081d7bd9b396bb18b0f4124613be
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ambv <lukasz at langa.pl>
date: 2021-08-02T18:39:25+02:00
summary:

bpo-44785: Silence deprecation warnings in test_pickle (GH-27538) (#27557)

(cherry picked from commit 36d952d228582b0ffc7a86c520d4ddbe8943d803)

Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>

files:
M Lib/test/test_pickle.py

diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py
index 2307b133dbd0d..70672dc19cf4a 100644
--- a/Lib/test/test_pickle.py
+++ b/Lib/test/test_pickle.py
@@ -6,6 +6,7 @@
 import collections
 import struct
 import sys
+import warnings
 import weakref
 
 import unittest
@@ -366,7 +367,10 @@ def getmodule(module):
         return sys.modules[module]
     except KeyError:
         try:
-            __import__(module)
+            with warnings.catch_warnings():
+                action = 'always' if support.verbose else 'ignore'
+                warnings.simplefilter(action, DeprecationWarning)
+                __import__(module)
         except AttributeError as exc:
             if support.verbose:
                 print("Can't import module %r: %s" % (module, exc))



More information about the Python-checkins mailing list