mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
bpo-41003: Fix test_copyreg when numpy is installed (GH-20935)
Fix test_copyreg when numpy is installed: test.pickletester now saves/restores warnings.filters when importing numpy, to ignore filters installed by numpy. Add the save_restore_warnings_filters() function to the test.support.warnings_helper module.
This commit is contained in:
parent
8e34e92caa
commit
8362893e3f
4 changed files with 29 additions and 12 deletions
|
@ -178,3 +178,12 @@ def _filterwarnings(filters, quiet=False):
|
|||
if missing:
|
||||
raise AssertionError("filter (%r, %s) did not catch any warning" %
|
||||
missing[0])
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def save_restore_warnings_filters():
|
||||
old_filters = warnings.filters[:]
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
warnings.filters[:] = old_filters
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue