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".
This commit is contained in:
Victor Stinner 2023-08-22 01:41:13 +02:00 committed by GitHub
parent a1cc74c4ee
commit 531930f47f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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, <class 'DeprecationWarning'>, 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.