Fix a bug introduced by the addition of the 'record' argument to
test.test_support.catch_warning() where showwarning() was not being set properly.
This commit is contained in:
parent
6071cc8fb0
commit
5d023c3afa
|
@ -406,11 +406,11 @@ def catch_warning(module=warnings, record=True):
|
||||||
warnings.warn("foo")
|
warnings.warn("foo")
|
||||||
assert str(w.message) == "foo"
|
assert str(w.message) == "foo"
|
||||||
"""
|
"""
|
||||||
|
original_filters = module.filters[:]
|
||||||
|
original_showwarning = module.showwarning
|
||||||
if record:
|
if record:
|
||||||
warning_obj = WarningMessage()
|
warning_obj = WarningMessage()
|
||||||
module.showwarning = warning_obj._showwarning
|
module.showwarning = warning_obj._showwarning
|
||||||
original_filters = module.filters[:]
|
|
||||||
original_showwarning = module.showwarning
|
|
||||||
try:
|
try:
|
||||||
yield warning_obj if record else None
|
yield warning_obj if record else None
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in New Issue