diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-07-19 02:50:51 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-07-19 02:50:51 (GMT) |
commit | e3d747496edf492c10e329512e1bab573843daf1 (patch) | |
tree | 6a7402f45a8af3d6f1c290294155dc7d27b1c672 /Lib/test/test_warnings/__init__.py | |
parent | 36261d7446c0b16d92467144a75ad1620e7d4b97 (diff) | |
parent | 221945056da4540506ff2303c07324e60b234e57 (diff) | |
download | cpython-e3d747496edf492c10e329512e1bab573843daf1.zip cpython-e3d747496edf492c10e329512e1bab573843daf1.tar.gz cpython-e3d747496edf492c10e329512e1bab573843daf1.tar.bz2 |
Issue #27528: Merge warning doc and test from 3.5
Diffstat (limited to 'Lib/test/test_warnings/__init__.py')
-rw-r--r-- | Lib/test/test_warnings/__init__.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_warnings/__init__.py b/Lib/test/test_warnings/__init__.py index e7b85f1..c11ee40 100644 --- a/Lib/test/test_warnings/__init__.py +++ b/Lib/test/test_warnings/__init__.py @@ -263,6 +263,18 @@ class FilterTests(BaseTest): self.assertEqual(str(w[-1].message), text) self.assertTrue(w[-1].category is UserWarning) + def test_message_matching(self): + with original_warnings.catch_warnings(record=True, + module=self.module) as w: + self.module.simplefilter("ignore", UserWarning) + self.module.filterwarnings("error", "match", UserWarning) + self.assertRaises(UserWarning, self.module.warn, "match") + self.assertRaises(UserWarning, self.module.warn, "match prefix") + self.module.warn("suffix match") + self.assertEqual(w, []) + self.module.warn("something completely different") + self.assertEqual(w, []) + def test_mutate_filter_list(self): class X: def match(self, a): |