]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-44785: Silence deprecation warnings in test_pickle (GH-27538) (#27557)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 2 Aug 2021 16:39:25 +0000 (09:39 -0700)
committerGitHub <noreply@github.com>
Mon, 2 Aug 2021 16:39:25 +0000 (18:39 +0200)
(cherry picked from commit 36d952d228582b0ffc7a86c520d4ddbe8943d803)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/test/test_pickle.py

index 2307b133dbd0d56485cfefab57878e02ac8cc1b4..70672dc19cf4af26bfc4f75ee1b4f6ba6de955a1 100644 (file)
@@ -6,6 +6,7 @@ import io
 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))