mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
[3.12] Fix test_generators: save/restore warnings filters (GH-108246) (#108249)
Fix test_generators: save/restore warnings filters (GH-108246)
Previously, depending on existing filters, the test
could modify the warnings and so fail as "env changed".
(cherry picked from commit 531930f47f)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
47f60c3f67
commit
b26a7b78c9
1 changed files with 2 additions and 2 deletions
|
|
@ -2176,6 +2176,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().
|
||||
|
|
@ -2249,8 +2250,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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue