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

(cherry picked from commit 36d952d228)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-08-02 10:09:05 -07:00 committed by GitHub
parent 2cc19a5463
commit aa7266854a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -6,6 +6,7 @@
import collections import collections
import struct import struct
import sys import sys
import warnings
import weakref import weakref
import unittest import unittest
@ -367,7 +368,10 @@ def getmodule(module):
return sys.modules[module] return sys.modules[module]
except KeyError: except KeyError:
try: try:
__import__(module) with warnings.catch_warnings():
action = 'always' if support.verbose else 'ignore'
warnings.simplefilter(action, DeprecationWarning)
__import__(module)
except AttributeError as exc: except AttributeError as exc:
if support.verbose: if support.verbose:
print("Can't import module %r: %s" % (module, exc)) print("Can't import module %r: %s" % (module, exc))