From: Victor Stinner Date: Mon, 21 Aug 2023 23:41:13 +0000 (+0200) Subject: Fix test_generators: save/restore warnings filters (#108246) X-Git-Tag: v3.13.0a1~866 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=531930f47f6b2a548d31e62cb4ad3e215a24bf53;p=thirdparty%2FPython%2Fcpython.git Fix test_generators: save/restore warnings filters (#108246) Previously, depending on existing filters, the test could modify the warnings and so fail as "env changed". --- diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index a8a344ab8de4..d48f0d47ba19 100644 --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -2258,6 +2258,7 @@ caught ValueError () caught ValueError (xyz) >>> import warnings +>>> old_filters = warnings.filters.copy() >>> warnings.filterwarnings("ignore", category=DeprecationWarning) # Filter DeprecationWarning: regarding the (type, val, tb) signature of throw(). @@ -2331,8 +2332,7 @@ Traceback (most recent call last): ... ValueError: 7 ->>> warnings.filters.pop(0) -('ignore', None, , None, 0) +>>> warnings.filters[:] = old_filters # Re-enable DeprecationWarning: the (type, val, tb) exception representation is deprecated, # and may be removed in a future version of Python.