Kaydet (Commit) d0aac5da authored tarafından Victor Stinner's avatar Victor Stinner Kaydeden (comit) GitHub

bpo-30812: Fix test_warnings, restore _showwarnmsg (#2504) (#2507)

bpo-26568, bpo-30812: Fix test_showwarnmsg_missing(): restore the
attribute after removing it.
(cherry picked from commit 7eebeb8f)
üst 6f3cb059
...@@ -727,10 +727,15 @@ class _WarningsTests(BaseTest, unittest.TestCase): ...@@ -727,10 +727,15 @@ class _WarningsTests(BaseTest, unittest.TestCase):
text = 'del _showwarnmsg test' text = 'del _showwarnmsg test'
with original_warnings.catch_warnings(module=self.module): with original_warnings.catch_warnings(module=self.module):
self.module.filterwarnings("always", category=UserWarning) self.module.filterwarnings("always", category=UserWarning)
del self.module._showwarnmsg
with support.captured_output('stderr') as stream: show = self.module._showwarnmsg
self.module.warn(text) try:
result = stream.getvalue() del self.module._showwarnmsg
with support.captured_output('stderr') as stream:
self.module.warn(text)
result = stream.getvalue()
finally:
self.module._showwarnmsg = show
self.assertIn(text, result) self.assertIn(text, result)
def test_showwarning_not_callable(self): def test_showwarning_not_callable(self):
......
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