summaryrefslogtreecommitdiff
path: root/Lib/test/pickletester.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-17 18:07:13 +0200
committerGitHub <noreply@github.com>2020-06-17 18:07:13 +0200
commit8362893e3fe083df2ec8bb94c28b1a78383eadbf (patch)
treec485a614b45419ebbd2b648de6e8e2efa2279515 /Lib/test/pickletester.py
parent8e34e92caa73259620dd242b92d26edd0949b4ba (diff)
downloadcpython-git-8362893e3fe083df2ec8bb94c28b1a78383eadbf.tar.gz
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.
Diffstat (limited to 'Lib/test/pickletester.py')
-rw-r--r--Lib/test/pickletester.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index ca566a28d6..a34505aab5 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -21,20 +21,26 @@ try:
except ImportError:
_testbuffer = None
-try:
- import numpy as np
-except ImportError:
- np = None
-
from test import support
from test.support import (
TestFailed, TESTFN, run_with_locale, no_tracing,
_2G, _4G, bigmemtest, forget,
)
from test.support import threading_helper
+from test.support.warnings_helper import save_restore_warnings_filters
from pickle import bytes_types
+
+# bpo-41003: Save/restore warnings filters to leave them unchanged.
+# Ignore filters installed by numpy.
+try:
+ with save_restore_warnings_filters():
+ import numpy as np
+except ImportError:
+ np = None
+
+
requires_32b = unittest.skipUnless(sys.maxsize < 2**32,
"test is only meaningful on 32-bit builds")