summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_exceptions.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-08-02 23:34:49 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2010-08-02 23:34:49 (GMT)
commit1d55ec329a08c2d022d4d83887bd71755bc52026 (patch)
tree01731ecfcdb5a5be08ff566febb4de0cc047636a /Lib/test/test_exceptions.py
parentcc436eb6e83f231c4d5c1bfdd8565b6b4b45effa (diff)
downloadcpython-1d55ec329a08c2d022d4d83887bd71755bc52026.zip
cpython-1d55ec329a08c2d022d4d83887bd71755bc52026.tar.gz
cpython-1d55ec329a08c2d022d4d83887bd71755bc52026.tar.bz2
Merged revisions 79539 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r79539 | florent.xicluna | 2010-04-01 01:01:03 +0300 (Thu, 01 Apr 2010) | 2 lines Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests. ........
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r--Lib/test/test_exceptions.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 43de4de..dcdd885 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -4,9 +4,9 @@ import os
import sys
import unittest
import pickle, cPickle
-import warnings
-from test.test_support import TESTFN, unlink, run_unittest, captured_output
+from test.test_support import (TESTFN, unlink, run_unittest, captured_output,
+ check_warnings)
from test.test_pep352 import ignore_deprecation_warnings
# XXX This is not really enough, each *operation* should be tested!
@@ -308,23 +308,19 @@ class ExceptionTests(unittest.TestCase):
# Accessing BaseException.message and relying on its value set by
# BaseException.__init__ triggers a deprecation warning.
exc = BaseException("foo")
- with warnings.catch_warnings(record=True) as w:
- self.assertEquals(exc.message, "foo")
- self.assertEquals(len(w), 1)
- self.assertEquals(w[0].category, DeprecationWarning)
- self.assertEquals(
- str(w[0].message),
- "BaseException.message has been deprecated as of Python 2.6")
-
+ with check_warnings(("BaseException.message has been deprecated "
+ "as of Python 2.6", DeprecationWarning)) as w:
+ self.assertEqual(exc.message, "foo")
+ self.assertEqual(len(w.warnings), 1)
def testRegularMessageAttribute(self):
# Accessing BaseException.message after explicitly setting a value
# for it does not trigger a deprecation warning.
exc = BaseException("foo")
exc.message = "bar"
- with warnings.catch_warnings(record=True) as w:
- self.assertEquals(exc.message, "bar")
- self.assertEquals(len(w), 0)
+ with check_warnings(quiet=True) as w:
+ self.assertEqual(exc.message, "bar")
+ self.assertEqual(len(w.warnings), 0)
# Deleting the message is supported, too.
del exc.message
self.assertRaises(AttributeError, getattr, exc, "message")