diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -13,7 +13,11 @@ import warnings as original_warnings py_warnings = support.import_fresh_module('warnings', blocked=['_warnings']) + +# Issue #18383: the 'sys.warnoptions' are inserted again on reload +nfilters = len(original_warnings.filters) c_warnings = support.import_fresh_module('warnings', fresh=['_warnings']) +del original_warnings.filters[:-nfilters] @contextmanager def warnings_state(module):