diff options
author | Victor Stinner <vstinner@python.org> | 2020-06-17 17:09:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-17 17:09:49 (GMT) |
commit | 3d974b2fc681ddd0ec722cf631008d5941da52b8 (patch) | |
tree | a95d07129031b90350b62f956bed5a07b55d6968 /Lib/test/support/__init__.py | |
parent | 071bed842eeff9673bc5c4f64e3916a151132d2a (diff) | |
download | cpython-3d974b2fc681ddd0ec722cf631008d5941da52b8.zip cpython-3d974b2fc681ddd0ec722cf631008d5941da52b8.tar.gz cpython-3d974b2fc681ddd0ec722cf631008d5941da52b8.tar.bz2 |
bpo-41003: Fix test_copyreg when numpy is installed (GH-20935) (GH-20945) (GH-20946)
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.
(cherry picked from commit 8362893e3fe083df2ec8bb94c28b1a78383eadbf)
(cherry picked from commit b39d41ba1b77f7bc51c4d6f6d0e336693192cb3a)
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r-- | Lib/test/support/__init__.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 08d53ec..0906e7a 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -3368,3 +3368,12 @@ class catch_threading_exception: del self.exc_value del self.exc_traceback del self.thread + + +@contextlib.contextmanager +def save_restore_warnings_filters(): + old_filters = warnings.filters[:] + try: + yield + finally: + warnings.filters[:] = old_filters |