warnings.catch_warnings() now returns a list or None instead of the custom
WarningsRecorder object. This makes the API simpler to use as no special object
must be learned.
Closes issue 3781.
Review by Benjamin Peterson.
diff --git a/Lib/test/test_pep352.py b/Lib/test/test_pep352.py
index 1867b9e..e335528 100644
--- a/Lib/test/test_pep352.py
+++ b/Lib/test/test_pep352.py
@@ -2,7 +2,7 @@
import __builtin__
import exceptions
import warnings
-from test.test_support import run_unittest, catch_warning
+from test.test_support import run_unittest
import os
from platform import system as platform_system
@@ -22,7 +22,7 @@
self.failUnless(issubclass(Exception, object))
def verify_instance_interface(self, ins):
- with catch_warning():
+ with warnings.catch_warnings():
ignore_message_warning()
for attr in ("args", "message", "__str__", "__repr__",
"__getitem__"):
@@ -95,7 +95,7 @@
# Make sure interface works properly when given a single argument
arg = "spam"
exc = Exception(arg)
- with catch_warning():
+ with warnings.catch_warnings():
ignore_message_warning()
results = ([len(exc.args), 1], [exc.args[0], arg],
[exc.message, arg],
@@ -109,7 +109,7 @@
arg_count = 3
args = tuple(range(arg_count))
exc = Exception(*args)
- with catch_warning():
+ with warnings.catch_warnings():
ignore_message_warning()
results = ([len(exc.args), arg_count], [exc.args, args],
[exc.message, ''], [str(exc), str(args)],
@@ -121,7 +121,7 @@
def test_interface_no_arg(self):
# Make sure that with no args that interface is correct
exc = Exception()
- with catch_warning():
+ with warnings.catch_warnings():
ignore_message_warning()
results = ([len(exc.args), 0], [exc.args, tuple()],
[exc.message, ''],
@@ -132,7 +132,7 @@
def test_message_deprecation(self):
# As of Python 2.6, BaseException.message is deprecated.
- with catch_warning():
+ with warnings.catch_warnings():
warnings.resetwarnings()
warnings.filterwarnings('error')
@@ -219,7 +219,7 @@
def test_catch_string(self):
# Catching a string should trigger a DeprecationWarning.
- with catch_warning():
+ with warnings.catch_warnings():
warnings.resetwarnings()
warnings.filterwarnings("error")
str_exc = "spam"