mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
be more robust against the filters list changing under us (closes #24096)
This commit is contained in:
parent
501182a47b
commit
deff2b76ec
3 changed files with 31 additions and 6 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue