Commit 0025eb14 authored by Victor Stinner's avatar Victor Stinner

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.
parent 43593a18
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment