mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
bpo-30812: Fix test_warnings, restore _showwarnmsg (#2504)
bpo-26568, bpo-30812: Fix test_showwarnmsg_missing(): restore the attribute after removing it.
This commit is contained in:
parent
e4f9a2d2be
commit
7eebeb8fb8
1 changed files with 9 additions and 4 deletions
|
|
@ -727,10 +727,15 @@ def test_showwarnmsg_missing(self):
|
|||
text = 'del _showwarnmsg test'
|
||||
with original_warnings.catch_warnings(module=self.module):
|
||||
self.module.filterwarnings("always", category=UserWarning)
|
||||
del self.module._showwarnmsg
|
||||
with support.captured_output('stderr') as stream:
|
||||
self.module.warn(text)
|
||||
result = stream.getvalue()
|
||||
|
||||
show = self.module._showwarnmsg
|
||||
try:
|
||||
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)
|
||||
|
||||
def test_showwarning_not_callable(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue