mirror of https://github.com/python/cpython
test_warnings: catch stderr and check warning
Check the user warning in test_error_after_default() to not pollute the output, and check the warning logged into stderr.
This commit is contained in:
parent
43593a1892
commit
0025eb145f
|
@ -104,7 +104,15 @@ class FilterTests(BaseTest):
|
|||
message = "FilterTests.test_ignore_after_default"
|
||||
def f():
|
||||
self.module.warn(message, UserWarning)
|
||||
f()
|
||||
|
||||
with support.captured_stderr() as stderr:
|
||||
f()
|
||||
stderr = stderr.getvalue()
|
||||
self.assertIn("UserWarning: FilterTests.test_ignore_after_default",
|
||||
stderr)
|
||||
self.assertIn("self.module.warn(message, UserWarning)",
|
||||
stderr)
|
||||
|
||||
self.module.filterwarnings("error", category=UserWarning)
|
||||
self.assertRaises(UserWarning, f)
|
||||
|
||||
|
|
Loading…
Reference in New Issue