Skip to content

Commit

Permalink
Fix test_generators: save/restore warnings filters (#108246)
Browse files Browse the repository at this point in the history
Previously, depending on existing filters, the test
could modify the warnings and so fail as "env changed".
  • Loading branch information
vstinner authored Aug 21, 2023
1 parent a1cc74c commit 531930f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/test/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2258,6 +2258,7 @@ def printsolution(self, x):
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().
Expand Down Expand Up @@ -2331,8 +2332,7 @@ def printsolution(self, x):
...
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.
Expand Down

0 comments on commit 531930f

Please sign in to comment.