diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-05-03 15:23:37 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-05-03 15:23:37 (GMT) |
commit | deff2b76ec3824ff238ad0812c29aca95534ecb4 (patch) | |
tree | 30da4f669fe250e74448d9a44221a50ca2b3027c /Lib/test/test_warnings.py | |
parent | 501182a47b722a02edd83a344ba53d06cd9afbd1 (diff) | |
download | cpython-deff2b76ec3824ff238ad0812c29aca95534ecb4.zip cpython-deff2b76ec3824ff238ad0812c29aca95534ecb4.tar.gz cpython-deff2b76ec3824ff238ad0812c29aca95534ecb4.tar.bz2 |
be more robust against the filters list changing under us (closes #24096)
Diffstat (limited to 'Lib/test/test_warnings.py')
-rw-r--r-- | Lib/test/test_warnings.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py index 10076af..68bac36 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -185,6 +185,18 @@ class FilterTests(BaseTest): self.assertEqual(str(w[-1].message), text) self.assertTrue(w[-1].category is UserWarning) + def test_mutate_filter_list(self): + class X: + def match(self, a): + L[:] = [] + + L = [("default",X(),UserWarning,X(),0) for i in range(2)] + with original_warnings.catch_warnings(record=True, + module=self.module) as w: + self.module.filters = L + self.module.warn_explicit(UserWarning("b"), None, "f.py", 42) + self.assertEqual(str(w[-1].message), "b") + class CFilterTests(FilterTests, unittest.TestCase): module = c_warnings |