From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 2 Aug 2021 17:09:05 +0000 (-0700) Subject: bpo-44785: Silence deprecation warnings in test_pickle (GH-27538) X-Git-Tag: v3.10.0rc1~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=aa7266854abc63524b4be40a3a83977b8ad166c6;p=thirdparty%2FPython%2Fcpython.git bpo-44785: Silence deprecation warnings in test_pickle (GH-27538) (cherry picked from commit 36d952d228582b0ffc7a86c520d4ddbe8943d803) Co-authored-by: Serhiy Storchaka --- diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index 23c7bd261e85..f8b43a1eb666 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -6,6 +6,7 @@ import io import collections import struct import sys +import warnings import weakref import unittest @@ -367,7 +368,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))