diff options
| author | Martin Panter <vadmium+py@gmail.com> | 2016-07-19 02:26:38 (GMT) |
|---|---|---|
| committer | Martin Panter <vadmium+py@gmail.com> | 2016-07-19 02:26:38 (GMT) |
| commit | cdb8be4f40f070b46e880d5cdef55ce0a4019f66 (patch) | |
| tree | 1374cf6d97167cd4dd752e2af0d14c03da37ae96 /Lib/test/test_warnings.py | |
| parent | 0c08fe09f9b3afdff8bed06f3839126c1c3e7daa (diff) | |
| download | cpython-cdb8be4f40f070b46e880d5cdef55ce0a4019f66.zip cpython-cdb8be4f40f070b46e880d5cdef55ce0a4019f66.tar.gz cpython-cdb8be4f40f070b46e880d5cdef55ce0a4019f66.tar.bz2 | |
Issue #27528: Document and test warning messages must match at beginning
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 bc7e398..607d9f9 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -205,6 +205,18 @@ class FilterTests(object): 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, []) + class CFilterTests(BaseTest, FilterTests): module = c_warnings |
