Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #14503 -- Unified multiple implementations of test cases assert…

…* methods that verify a given exception is raised by a callable throughout the Django test suite.

Replaced them with a new assertRaisesMessage method of a new SimpleTestCase, a lightweight subclass of unittest.TestCase. Both are also available for usage in user tests.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16610 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 326949e444bcdde966d2421e2fb8bd8c87c65941 1 parent a539d43
Ramiro Morales authored August 13, 2011
3  django/test/__init__.py
@@ -3,5 +3,6 @@
3 3
 """
4 4
 
5 5
 from django.test.client import Client, RequestFactory
6  
-from django.test.testcases import TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature
  6
+from django.test.testcases import (TestCase, TransactionTestCase,
  7
+        SimpleTestCase, skipIfDBFeature, skipUnlessDBFeature)
7 8
 from django.test.utils import Approximate
59  django/test/testcases.py
@@ -21,7 +21,7 @@
21 21
 from django.utils.encoding import smart_str
22 22
 
23 23
 __all__ = ('DocTestRunner', 'OutputChecker', 'TestCase', 'TransactionTestCase',
24  
-           'skipIfDBFeature', 'skipUnlessDBFeature')
  24
+           'SimpleTestCase', 'skipIfDBFeature', 'skipUnlessDBFeature')
25 25
 
26 26
 normalize_long_ints = lambda s: re.sub(r'(?<![\w])(\d+)L(?![\w])', '\\1', s)
27 27
 normalize_decimals = lambda s: re.sub(r"Decimal\('(\d+(\.\d*)?)'\)", lambda m: "Decimal(\"%s\")" % m.groups()[0], s)
@@ -235,8 +235,43 @@ def __exit__(self, exc_type, exc_value, traceback):
235 235
             )
236 236
         )
237 237
 
  238
+class SimpleTestCase(ut2.TestCase):
238 239
 
239  
-class TransactionTestCase(ut2.TestCase):
  240
+    def save_warnings_state(self):
  241
+        """
  242
+        Saves the state of the warnings module
  243
+        """
  244
+        self._warnings_state = get_warnings_state()
  245
+
  246
+    def restore_warnings_state(self):
  247
+        """
  248
+        Restores the sate of the warnings module to the state
  249
+        saved by save_warnings_state()
  250
+        """
  251
+        restore_warnings_state(self._warnings_state)
  252
+
  253
+    def settings(self, **kwargs):
  254
+        """
  255
+        A context manager that temporarily sets a setting and reverts
  256
+        back to the original value when exiting the context.
  257
+        """
  258
+        return override_settings(**kwargs)
  259
+
  260
+    def assertRaisesMessage(self, expected_exception, expected_message,
  261
+                           callable_obj=None, *args, **kwargs):
  262
+        """Asserts that the message in a raised exception matches the passe value.
  263
+
  264
+        Args:
  265
+            expected_exception: Exception class expected to be raised.
  266
+            expected_message: expected error message string value.
  267
+            callable_obj: Function to be called.
  268
+            args: Extra args.
  269
+            kwargs: Extra kwargs.
  270
+        """
  271
+        return self.assertRaisesRegexp(expected_exception,
  272
+                re.escape(expected_message), callable_obj, *args, **kwargs)
  273
+
  274
+class TransactionTestCase(SimpleTestCase):
240 275
     # The class we'll use for the test client self.client.
241 276
     # Can be overridden in derived classes.
242 277
     client_class = Client
@@ -332,26 +367,6 @@ def _urlconf_teardown(self):
332 367
             settings.ROOT_URLCONF = self._old_root_urlconf
333 368
             clear_url_caches()
334 369
 
335  
-    def save_warnings_state(self):
336  
-        """
337  
-        Saves the state of the warnings module
338  
-        """
339  
-        self._warnings_state = get_warnings_state()
340  
-
341  
-    def restore_warnings_state(self):
342  
-        """
343  
-        Restores the sate of the warnings module to the state
344  
-        saved by save_warnings_state()
345  
-        """
346  
-        restore_warnings_state(self._warnings_state)
347  
-
348  
-    def settings(self, **kwargs):
349  
-        """
350  
-        A context manager that temporarily sets a setting and reverts
351  
-        back to the original value when exiting the context.
352  
-        """
353  
-        return override_settings(**kwargs)
354  
-
355 370
     def assertRedirects(self, response, expected_url, status_code=302,
356 371
                         target_status_code=200, host=None, msg_prefix=''):
357 372
         """Asserts that a response redirected to a specific URL, and that the
2  docs/ref/signals.txt
@@ -480,7 +480,7 @@ setting_changed
480 480
 .. data:: django.test.signals.setting_changed
481 481
    :module:
482 482
 
483  
-Sent when some :ref:`settings are overridden <overriding-setting>` with the
  483
+Sent when some :ref:`settings are overridden <overriding-settings>` with the
484 484
 :meth:`django.test.TestCase.setting` context manager or the
485 485
 :func:`django.test.utils.override_settings` decorator/context manager.
486 486
 
70  docs/topics/testing.txt
@@ -715,7 +715,7 @@ arguments at time of construction:
715 715
             The headers sent via ``**extra`` should follow CGI_ specification.
716 716
             For example, emulating a different "Host" header as sent in the
717 717
             HTTP request from the browser to the server should be passed
718  
-            as ``HTTP_HOST``. 
  718
+            as ``HTTP_HOST``.
719 719
 
720 720
             .. _CGI: http://www.w3.org/CGI/
721 721
 
@@ -1101,7 +1101,7 @@ TestCase
1101 1101
 .. currentmodule:: django.test
1102 1102
 
1103 1103
 Normal Python unit test classes extend a base class of ``unittest.TestCase``.
1104  
-Django provides an extension of this base class:
  1104
+Django provides a few extensions of this base class:
1105 1105
 
1106 1106
 .. class:: TestCase()
1107 1107
 
@@ -1123,6 +1123,8 @@ additions, including:
1123 1123
     * Django-specific assertions for testing for things
1124 1124
       like redirection and form errors.
1125 1125
 
  1126
+``TestCase`` inherits from :class:`~django.test.TransactionTestCase`.
  1127
+
1126 1128
 .. class:: TransactionTestCase()
1127 1129
 
1128 1130
 Django ``TestCase`` classes make use of database transaction facilities, if
@@ -1153,6 +1155,7 @@ When running on a database that does not support rollback (e.g. MySQL with the
1153 1155
 MyISAM storage engine), ``TestCase`` falls back to initializing the database
1154 1156
 by truncating tables and reloading initial data.
1155 1157
 
  1158
+``TransactionTestCase`` inherits from :class:`~django.test.SimpleTestCase`.
1156 1159
 
1157 1160
 .. note::
1158 1161
     The ``TestCase`` use of rollback to un-do the effects of the test code
@@ -1166,6 +1169,31 @@ by truncating tables and reloading initial data.
1166 1169
     A better long-term fix, that allows the test to take advantage of the
1167 1170
     speed benefit of ``TestCase``, is to fix the underlying test problem.
1168 1171
 
  1172
+.. class:: SimpleTestCase()
  1173
+
  1174
+.. versionadded:: 1.4
  1175
+
  1176
+A very thin subclass of :class:`unittest.TestCase`, it extends it with some
  1177
+basic functionality like:
  1178
+
  1179
+ * Saving and restoring the Python warning machinery state.
  1180
+ * Checking that a callable :meth:`raises a certain exeception <TestCase.assertRaisesMessage>`.
  1181
+
  1182
+If you need any of the other more complex and heavyweight Django-specific
  1183
+features like:
  1184
+
  1185
+ * The ability to run tests with :ref:`modified settings <overriding-settings>`
  1186
+ * Using the :attr:`~TestCase.client` :class:`~django.test.client.Client`.
  1187
+ * Testing or using the ORM.
  1188
+ * Database :attr:`~TestCase.fixtures`.
  1189
+ * Custom test-time :attr:`URL maps <TestCase.urls>`.
  1190
+ * Test :ref:`skipping based on database backend features <skipping-tests>`.
  1191
+ * Our specialized :ref:`assert* <assertions>` metods.
  1192
+
  1193
+then you should use :class:`~django.test.TransactionTestCase` or
  1194
+:class:`~django.test.TestCase` instead.
  1195
+
  1196
+``SimpleTestCase`` inherits from :class:`django.utils.unittest.TestCase`.
1169 1197
 
1170 1198
 Default test client
1171 1199
 ~~~~~~~~~~~~~~~~~~~
@@ -1370,7 +1398,7 @@ For example::
1370 1398
 This test case will flush *all* the test databases before running
1371 1399
 ``testIndexPageView``.
1372 1400
 
1373  
-.. _overriding-setting:
  1401
+.. _overriding-settings:
1374 1402
 
1375 1403
 Overriding settings
1376 1404
 ~~~~~~~~~~~~~~~~~~~
@@ -1402,7 +1430,9 @@ this use case Django provides a standard `Python context manager`_
1402 1430
 This example will override the :setting:`LOGIN_URL` setting for the code
1403 1431
 in the ``with`` block and reset its value to the previous state afterwards.
1404 1432
 
1405  
-.. function:: utils.override_settings
  1433
+.. currentmodule:: django.test.utils
  1434
+
  1435
+.. function:: override_settings
1406 1436
 
1407 1437
 In case you want to override a setting for just one test method or even the
1408 1438
 whole TestCase class, Django provides the
@@ -1463,9 +1493,13 @@ contents of the test email outbox at the start of each test case.
1463 1493
 
1464 1494
 For more detail on email services during tests, see `Email services`_.
1465 1495
 
  1496
+.. _assertions:
  1497
+
1466 1498
 Assertions
1467 1499
 ~~~~~~~~~~
1468 1500
 
  1501
+.. currentmodule:: django.test
  1502
+
1469 1503
 .. versionchanged:: 1.2
1470 1504
     Addded ``msg_prefix`` argument.
1471 1505
 
@@ -1474,11 +1508,19 @@ such as ``assertTrue`` and ``assertEqual``, Django's custom ``TestCase`` class
1474 1508
 provides a number of custom assertion methods that are useful for testing Web
1475 1509
 applications:
1476 1510
 
1477  
-The failure messages given by the assertion methods can be customized
1478  
-with the ``msg_prefix`` argument. This string will be prefixed to any
1479  
-failure message generated by the assertion. This allows you to provide
1480  
-additional details that may help you to identify the location and
1481  
-cause of an failure in your test suite.
  1511
+The failure messages given by most of these assertion methods can be customized
  1512
+with the ``msg_prefix`` argument. This string will be prefixed to any failure
  1513
+message generated by the assertion. This allows you to provide additional
  1514
+details that may help you to identify the location and cause of an failure in
  1515
+your test suite.
  1516
+
  1517
+.. method:: TestCase.assertRaisesMessage(expected_exception, expected_message, callable_obj=None, *args, **kwargs)
  1518
+
  1519
+    Asserts that execution of callable ``callable_obj`` raised the
  1520
+    ``expected_exception`` exception and that such exception has an
  1521
+    ``expected_message`` representation. Any other outcome is reported as a
  1522
+    failure. Similar to unittest's ``assertRaisesRegexp`` with the difference
  1523
+    that ``expected_message`` isn't a regular expression.
1482 1524
 
1483 1525
 .. method:: TestCase.assertContains(response, text, count=None, status_code=200, msg_prefix='')
1484 1526
 
@@ -1626,9 +1668,13 @@ manually, assign the empty list to ``mail.outbox``::
1626 1668
     # Empty the test outbox
1627 1669
     mail.outbox = []
1628 1670
 
  1671
+.. _skipping-tests:
  1672
+
1629 1673
 Skipping tests
1630 1674
 --------------
1631 1675
 
  1676
+.. currentmodule:: django.test
  1677
+
1632 1678
 .. versionadded:: 1.3
1633 1679
 
1634 1680
 The unittest library provides the ``@skipIf`` and ``@skipUnless``
@@ -1651,8 +1697,7 @@ features class. See :class:`~django.db.backends.BaseDatabaseFeatures`
1651 1697
 class for a full list of database features that can be used as a basis
1652 1698
 for skipping tests.
1653 1699
 
1654  
-skipIfDBFeature
1655  
-~~~~~~~~~~~~~~~
  1700
+.. function:: skipIfDBFeature(feature_name_string)
1656 1701
 
1657 1702
 Skip the decorated test if the named database feature is supported.
1658 1703
 
@@ -1665,8 +1710,7 @@ it would under MySQL with MyISAM tables)::
1665 1710
         def test_transaction_behavior(self):
1666 1711
             # ... conditional test code
1667 1712
 
1668  
-skipUnlessDBFeature
1669  
-~~~~~~~~~~~~~~~~~~~
  1713
+.. function:: skipUnlessDBFeature(feature_name_string)
1670 1714
 
1671 1715
 Skip the decorated test if the named database feature is *not*
1672 1716
 supported.
6  tests/regressiontests/admin_validation/tests.py
@@ -19,12 +19,6 @@ class InvalidFields(admin.ModelAdmin):
19 19
     fields = ['spam']
20 20
 
21 21
 class ValidationTestCase(TestCase):
22  
-    def assertRaisesMessage(self, exc, msg, func, *args, **kwargs):
23  
-        try:
24  
-            func(*args, **kwargs)
25  
-        except Exception, e:
26  
-            self.assertEqual(msg, str(e))
27  
-            self.assertTrue(isinstance(e, exc), "Expected %s, got %s" % (exc, type(e)))
28 22
 
29 23
     def test_readonly_and_editable(self):
30 24
         class SongAdmin(admin.ModelAdmin):
7  tests/regressiontests/custom_columns_regress/tests.py
@@ -9,13 +9,6 @@ def pks(objects):
9 9
 
10 10
 class CustomColumnRegression(TestCase):
11 11
 
12  
-    def assertRaisesMessage(self, exc, msg, func, *args, **kwargs):
13  
-        try:
14  
-            func(*args, **kwargs)
15  
-        except Exception, e:
16  
-            self.assertEqual(msg, str(e))
17  
-            self.assertTrue(isinstance(e, exc), "Expected %s, got %s" % (exc, type(e)))
18  
-
19 12
     def setUp(self):
20 13
         self.a1 = Author.objects.create(first_name='John', last_name='Smith')
21 14
         self.a2 = Author.objects.create(first_name='Peter', last_name='Jones')
14  tests/regressiontests/file_storage/tests.py
@@ -22,6 +22,7 @@
22 22
 from django.core.files.images import get_image_dimensions
23 23
 from django.core.files.storage import FileSystemStorage, get_storage_class
24 24
 from django.core.files.uploadedfile import UploadedFile
  25
+from django.test import SimpleTestCase
25 26
 from django.utils import unittest
26 27
 
27 28
 # Try to import PIL in either of the two ways it can end up installed.
@@ -36,14 +37,7 @@
36 37
         Image = None
37 38
 
38 39
 
39  
-class GetStorageClassTests(unittest.TestCase):
40  
-    def assertRaisesErrorWithMessage(self, error, message, callable,
41  
-        *args, **kwargs):
42  
-        self.assertRaises(error, callable, *args, **kwargs)
43  
-        try:
44  
-            callable(*args, **kwargs)
45  
-        except error, e:
46  
-            self.assertEqual(message, str(e))
  40
+class GetStorageClassTests(SimpleTestCase):
47 41
 
48 42
     def test_get_filesystem_storage(self):
49 43
         """
@@ -57,7 +51,7 @@ def test_get_invalid_storage_module(self):
57 51
         """
58 52
         get_storage_class raises an error if the requested import don't exist.
59 53
         """
60  
-        self.assertRaisesErrorWithMessage(
  54
+        self.assertRaisesMessage(
61 55
             ImproperlyConfigured,
62 56
             "NonExistingStorage isn't a storage module.",
63 57
             get_storage_class,
@@ -67,7 +61,7 @@ def test_get_nonexisting_storage_class(self):
67 61
         """
68 62
         get_storage_class raises an error if the requested class don't exist.
69 63
         """
70  
-        self.assertRaisesErrorWithMessage(
  64
+        self.assertRaisesMessage(
71 65
             ImproperlyConfigured,
72 66
             'Storage module "django.core.files.storage" does not define a '\
73 67
                 '"NonExistingStorage" class.',
6  tests/regressiontests/fixtures_regress/tests.py
@@ -393,12 +393,6 @@ def test_loaddata_raises_error_when_fixture_has_invalid_foreign_key(self):
393 393
 
394 394
 
395 395
 class NaturalKeyFixtureTests(TestCase):
396  
-    def assertRaisesMessage(self, exc, msg, func, *args, **kwargs):
397  
-        try:
398  
-            func(*args, **kwargs)
399  
-        except Exception, e:
400  
-            self.assertEqual(msg, str(e))
401  
-            self.assertTrue(isinstance(e, exc), "Expected %s, got %s" % (exc, type(e)))
402 396
 
403 397
     def test_nk_deserialize(self):
404 398
         """
359  tests/regressiontests/forms/tests/fields.py
@@ -33,7 +33,7 @@
33 33
 
34 34
 from django.core.files.uploadedfile import SimpleUploadedFile
35 35
 from django.forms import *
36  
-from django.utils.unittest import TestCase
  36
+from django.test import SimpleTestCase
37 37
 
38 38
 
39 39
 def fix_os_paths(x):
@@ -69,14 +69,7 @@ def urlopen(req):
69 69
     return decorator
70 70
 
71 71
 
72  
-class FieldsTests(TestCase):
73  
-
74  
-    def assertRaisesErrorWithMessage(self, error, message, callable, *args, **kwargs):
75  
-        self.assertRaises(error, callable, *args, **kwargs)
76  
-        try:
77  
-            callable(*args, **kwargs)
78  
-        except error, e:
79  
-            self.assertEqual(message, str(e))
  72
+class FieldsTests(SimpleTestCase):
80 73
 
81 74
     def test_field_sets_widget_is_required(self):
82 75
         self.assertTrue(Field(required=True).widget.is_required)
@@ -88,8 +81,8 @@ def test_charfield_1(self):
88 81
         f = CharField()
89 82
         self.assertEqual(u'1', f.clean(1))
90 83
         self.assertEqual(u'hello', f.clean('hello'))
91  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
92  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  84
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  85
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
93 86
         self.assertEqual(u'[1, 2, 3]', f.clean([1, 2, 3]))
94 87
         self.assertEqual(f.max_length, None)
95 88
         self.assertEqual(f.min_length, None)
@@ -108,14 +101,14 @@ def test_charfield_3(self):
108 101
         f = CharField(max_length=10, required=False)
109 102
         self.assertEqual(u'12345', f.clean('12345'))
110 103
         self.assertEqual(u'1234567890', f.clean('1234567890'))
111  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at most 10 characters (it has 11).']", f.clean, '1234567890a')
  104
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at most 10 characters (it has 11).']", f.clean, '1234567890a')
112 105
         self.assertEqual(f.max_length, 10)
113 106
         self.assertEqual(f.min_length, None)
114 107
 
115 108
     def test_charfield_4(self):
116 109
         f = CharField(min_length=10, required=False)
117 110
         self.assertEqual(u'', f.clean(''))
118  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at least 10 characters (it has 5).']", f.clean, '12345')
  111
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at least 10 characters (it has 5).']", f.clean, '12345')
119 112
         self.assertEqual(u'1234567890', f.clean('1234567890'))
120 113
         self.assertEqual(u'1234567890a', f.clean('1234567890a'))
121 114
         self.assertEqual(f.max_length, None)
@@ -123,8 +116,8 @@ def test_charfield_4(self):
123 116
 
124 117
     def test_charfield_5(self):
125 118
         f = CharField(min_length=10, required=True)
126  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
127  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at least 10 characters (it has 5).']", f.clean, '12345')
  119
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  120
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at least 10 characters (it has 5).']", f.clean, '12345')
128 121
         self.assertEqual(u'1234567890', f.clean('1234567890'))
129 122
         self.assertEqual(u'1234567890a', f.clean('1234567890a'))
130 123
         self.assertEqual(f.max_length, None)
@@ -134,18 +127,18 @@ def test_charfield_5(self):
134 127
 
135 128
     def test_integerfield_1(self):
136 129
         f = IntegerField()
137  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
138  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  130
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  131
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
139 132
         self.assertEqual(1, f.clean('1'))
140 133
         self.assertEqual(True, isinstance(f.clean('1'), int))
141 134
         self.assertEqual(23, f.clean('23'))
142  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a whole number.']", f.clean, 'a')
  135
+        self.assertRaisesMessage(ValidationError, "[u'Enter a whole number.']", f.clean, 'a')
143 136
         self.assertEqual(42, f.clean(42))
144  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a whole number.']", f.clean, 3.14)
  137
+        self.assertRaisesMessage(ValidationError, "[u'Enter a whole number.']", f.clean, 3.14)
145 138
         self.assertEqual(1, f.clean('1 '))
146 139
         self.assertEqual(1, f.clean(' 1'))
147 140
         self.assertEqual(1, f.clean(' 1 '))
148  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a whole number.']", f.clean, '1a')
  141
+        self.assertRaisesMessage(ValidationError, "[u'Enter a whole number.']", f.clean, '1a')
149 142
         self.assertEqual(f.max_value, None)
150 143
         self.assertEqual(f.min_value, None)
151 144
 
@@ -158,29 +151,29 @@ def test_integerfield_2(self):
158 151
         self.assertEqual(1, f.clean('1'))
159 152
         self.assertEqual(True, isinstance(f.clean('1'), int))
160 153
         self.assertEqual(23, f.clean('23'))
161  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a whole number.']", f.clean, 'a')
  154
+        self.assertRaisesMessage(ValidationError, "[u'Enter a whole number.']", f.clean, 'a')
162 155
         self.assertEqual(1, f.clean('1 '))
163 156
         self.assertEqual(1, f.clean(' 1'))
164 157
         self.assertEqual(1, f.clean(' 1 '))
165  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a whole number.']", f.clean, '1a')
  158
+        self.assertRaisesMessage(ValidationError, "[u'Enter a whole number.']", f.clean, '1a')
166 159
         self.assertEqual(f.max_value, None)
167 160
         self.assertEqual(f.min_value, None)
168 161
 
169 162
     def test_integerfield_3(self):
170 163
         f = IntegerField(max_value=10)
171  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  164
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
172 165
         self.assertEqual(1, f.clean(1))
173 166
         self.assertEqual(10, f.clean(10))
174  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is less than or equal to 10.']", f.clean, 11)
  167
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is less than or equal to 10.']", f.clean, 11)
175 168
         self.assertEqual(10, f.clean('10'))
176  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is less than or equal to 10.']", f.clean, '11')
  169
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is less than or equal to 10.']", f.clean, '11')
177 170
         self.assertEqual(f.max_value, 10)
178 171
         self.assertEqual(f.min_value, None)
179 172
 
180 173
     def test_integerfield_4(self):
181 174
         f = IntegerField(min_value=10)
182  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
183  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is greater than or equal to 10.']", f.clean, 1)
  175
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  176
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is greater than or equal to 10.']", f.clean, 1)
184 177
         self.assertEqual(10, f.clean(10))
185 178
         self.assertEqual(11, f.clean(11))
186 179
         self.assertEqual(10, f.clean('10'))
@@ -190,14 +183,14 @@ def test_integerfield_4(self):
190 183
 
191 184
     def test_integerfield_5(self):
192 185
         f = IntegerField(min_value=10, max_value=20)
193  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
194  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is greater than or equal to 10.']", f.clean, 1)
  186
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  187
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is greater than or equal to 10.']", f.clean, 1)
195 188
         self.assertEqual(10, f.clean(10))
196 189
         self.assertEqual(11, f.clean(11))
197 190
         self.assertEqual(10, f.clean('10'))
198 191
         self.assertEqual(11, f.clean('11'))
199 192
         self.assertEqual(20, f.clean(20))
200  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is less than or equal to 20.']", f.clean, 21)
  193
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is less than or equal to 20.']", f.clean, 21)
201 194
         self.assertEqual(f.max_value, 20)
202 195
         self.assertEqual(f.min_value, 10)
203 196
 
@@ -205,19 +198,19 @@ def test_integerfield_5(self):
205 198
 
206 199
     def test_floatfield_1(self):
207 200
         f = FloatField()
208  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
209  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  201
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  202
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
210 203
         self.assertEqual(1.0, f.clean('1'))
211 204
         self.assertEqual(True, isinstance(f.clean('1'), float))
212 205
         self.assertEqual(23.0, f.clean('23'))
213 206
         self.assertEqual(3.1400000000000001, f.clean('3.14'))
214 207
         self.assertEqual(3.1400000000000001, f.clean(3.14))
215 208
         self.assertEqual(42.0, f.clean(42))
216  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, 'a')
  209
+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, 'a')
217 210
         self.assertEqual(1.0, f.clean('1.0 '))
218 211
         self.assertEqual(1.0, f.clean(' 1.0'))
219 212
         self.assertEqual(1.0, f.clean(' 1.0 '))
220  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, '1.0a')
  213
+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, '1.0a')
221 214
         self.assertEqual(f.max_value, None)
222 215
         self.assertEqual(f.min_value, None)
223 216
 
@@ -231,8 +224,8 @@ def test_floatfield_2(self):
231 224
 
232 225
     def test_floatfield_3(self):
233 226
         f = FloatField(max_value=1.5, min_value=0.5)
234  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is less than or equal to 1.5.']", f.clean, '1.6')
235  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is greater than or equal to 0.5.']", f.clean, '0.4')
  227
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is less than or equal to 1.5.']", f.clean, '1.6')
  228
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is greater than or equal to 0.5.']", f.clean, '0.4')
236 229
         self.assertEqual(1.5, f.clean('1.5'))
237 230
         self.assertEqual(0.5, f.clean('0.5'))
238 231
         self.assertEqual(f.max_value, 1.5)
@@ -242,34 +235,34 @@ def test_floatfield_3(self):
242 235
 
243 236
     def test_decimalfield_1(self):
244 237
         f = DecimalField(max_digits=4, decimal_places=2)
245  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
246  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  238
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  239
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
247 240
         self.assertEqual(f.clean('1'), Decimal("1"))
248 241
         self.assertEqual(True, isinstance(f.clean('1'), Decimal))
249 242
         self.assertEqual(f.clean('23'), Decimal("23"))
250 243
         self.assertEqual(f.clean('3.14'), Decimal("3.14"))
251 244
         self.assertEqual(f.clean(3.14), Decimal("3.14"))
252 245
         self.assertEqual(f.clean(Decimal('3.14')), Decimal("3.14"))
253  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, 'NaN')
254  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, 'Inf')
255  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, '-Inf')
256  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, 'a')
257  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, u'łąść')
  246
+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, 'NaN')
  247
+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, 'Inf')
  248
+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, '-Inf')
  249
+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, 'a')
  250
+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, u'łąść')
258 251
         self.assertEqual(f.clean('1.0 '), Decimal("1.0"))
259 252
         self.assertEqual(f.clean(' 1.0'), Decimal("1.0"))
260 253
         self.assertEqual(f.clean(' 1.0 '), Decimal("1.0"))
261  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, '1.0a')
262  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 4 digits in total.']", f.clean, '123.45')
263  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 2 decimal places.']", f.clean, '1.234')
264  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 2 digits before the decimal point.']", f.clean, '123.4')
  254
+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, '1.0a')
  255
+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 4 digits in total.']", f.clean, '123.45')
  256
+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 2 decimal places.']", f.clean, '1.234')
  257
+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 2 digits before the decimal point.']", f.clean, '123.4')
265 258
         self.assertEqual(f.clean('-12.34'), Decimal("-12.34"))
266  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 4 digits in total.']", f.clean, '-123.45')
  259
+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 4 digits in total.']", f.clean, '-123.45')
267 260
         self.assertEqual(f.clean('-.12'), Decimal("-0.12"))
268 261
         self.assertEqual(f.clean('-00.12'), Decimal("-0.12"))
269 262
         self.assertEqual(f.clean('-000.12'), Decimal("-0.12"))
270  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 2 decimal places.']", f.clean, '-000.123')
271  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 4 digits in total.']", f.clean, '-000.12345')
272  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, '--0.12')
  263
+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 2 decimal places.']", f.clean, '-000.123')
  264
+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 4 digits in total.']", f.clean, '-000.12345')
  265
+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, '--0.12')
273 266
         self.assertEqual(f.max_digits, 4)
274 267
         self.assertEqual(f.decimal_places, 2)
275 268
         self.assertEqual(f.max_value, None)
@@ -287,8 +280,8 @@ def test_decimalfield_2(self):
287 280
 
288 281
     def test_decimalfield_3(self):
289 282
         f = DecimalField(max_digits=4, decimal_places=2, max_value=Decimal('1.5'), min_value=Decimal('0.5'))
290  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is less than or equal to 1.5.']", f.clean, '1.6')
291  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is greater than or equal to 0.5.']", f.clean, '0.4')
  283
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is less than or equal to 1.5.']", f.clean, '1.6')
  284
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is greater than or equal to 0.5.']", f.clean, '0.4')
292 285
         self.assertEqual(f.clean('1.5'), Decimal("1.5"))
293 286
         self.assertEqual(f.clean('0.5'), Decimal("0.5"))
294 287
         self.assertEqual(f.clean('.5'), Decimal("0.5"))
@@ -300,7 +293,7 @@ def test_decimalfield_3(self):
300 293
 
301 294
     def test_decimalfield_4(self):
302 295
         f = DecimalField(decimal_places=2)
303  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 2 decimal places.']", f.clean, '0.00000001')
  296
+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 2 decimal places.']", f.clean, '0.00000001')
304 297
 
305 298
     def test_decimalfield_5(self):
306 299
         f = DecimalField(max_digits=3)
@@ -310,13 +303,13 @@ def test_decimalfield_5(self):
310 303
         self.assertEqual(f.clean('0000000.100'), Decimal("0.100"))
311 304
         # Only leading whole zeros "collapse" to one digit.
312 305
         self.assertEqual(f.clean('000000.02'), Decimal('0.02'))
313  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 3 digits in total.']", f.clean, '000000.0002')
  306
+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 3 digits in total.']", f.clean, '000000.0002')
314 307
         self.assertEqual(f.clean('.002'), Decimal("0.002"))
315 308
 
316 309
     def test_decimalfield_6(self):
317 310
         f = DecimalField(max_digits=2, decimal_places=2)
318 311
         self.assertEqual(f.clean('.01'), Decimal(".01"))
319  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 0 digits before the decimal point.']", f.clean, '1.1')
  312
+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 0 digits before the decimal point.']", f.clean, '1.1')
320 313
 
321 314
     # DateField ###################################################################
322 315
 
@@ -334,10 +327,10 @@ def test_datefield_1(self):
334 327
         self.assertEqual(datetime.date(2006, 10, 25), f.clean('October 25, 2006'))
335 328
         self.assertEqual(datetime.date(2006, 10, 25), f.clean('25 October 2006'))
336 329
         self.assertEqual(datetime.date(2006, 10, 25), f.clean('25 October, 2006'))
337  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '2006-4-31')
338  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '200a-10-25')
339  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '25/10/06')
340  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  330
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '2006-4-31')
  331
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '200a-10-25')
  332
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '25/10/06')
  333
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
341 334
 
342 335
     def test_datefield_2(self):
343 336
         f = DateField(required=False)
@@ -351,9 +344,9 @@ def test_datefield_3(self):
351 344
         self.assertEqual(datetime.date(2006, 10, 25), f.clean(datetime.date(2006, 10, 25)))
352 345
         self.assertEqual(datetime.date(2006, 10, 25), f.clean(datetime.datetime(2006, 10, 25, 14, 30)))
353 346
         self.assertEqual(datetime.date(2006, 10, 25), f.clean('2006 10 25'))
354  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '2006-10-25')
355  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '10/25/2006')
356  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '10/25/06')
  347
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '2006-10-25')
  348
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '10/25/2006')
  349
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '10/25/06')
357 350
 
358 351
     def test_datefield_4(self):
359 352
         # Test whitespace stripping behavior (#5714)
@@ -364,7 +357,7 @@ def test_datefield_4(self):
364 357
         self.assertEqual(datetime.date(2006, 10, 25), f.clean(' October  25 2006 '))
365 358
         self.assertEqual(datetime.date(2006, 10, 25), f.clean(' October 25, 2006 '))
366 359
         self.assertEqual(datetime.date(2006, 10, 25), f.clean(' 25 October 2006 '))
367  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '   ')
  360
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '   ')
368 361
 
369 362
     # TimeField ###################################################################
370 363
 
@@ -374,8 +367,8 @@ def test_timefield_1(self):
374 367
         self.assertEqual(datetime.time(14, 25, 59), f.clean(datetime.time(14, 25, 59)))
375 368
         self.assertEqual(datetime.time(14, 25), f.clean('14:25'))
376 369
         self.assertEqual(datetime.time(14, 25, 59), f.clean('14:25:59'))
377  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid time.']", f.clean, 'hello')
378  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid time.']", f.clean, '1:24 p.m.')
  370
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid time.']", f.clean, 'hello')
  371
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid time.']", f.clean, '1:24 p.m.')
379 372
 
380 373
     def test_timefield_2(self):
381 374
         f = TimeField(input_formats=['%I:%M %p'])
@@ -383,14 +376,14 @@ def test_timefield_2(self):
383 376
         self.assertEqual(datetime.time(14, 25, 59), f.clean(datetime.time(14, 25, 59)))
384 377
         self.assertEqual(datetime.time(4, 25), f.clean('4:25 AM'))
385 378
         self.assertEqual(datetime.time(16, 25), f.clean('4:25 PM'))
386  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid time.']", f.clean, '14:30:45')
  379
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid time.']", f.clean, '14:30:45')
387 380
 
388 381
     def test_timefield_3(self):
389 382
         f = TimeField()
390 383
         # Test whitespace stripping behavior (#5714)
391 384
         self.assertEqual(datetime.time(14, 25), f.clean(' 14:25 '))
392 385
         self.assertEqual(datetime.time(14, 25, 59), f.clean(' 14:25:59 '))
393  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid time.']", f.clean, '   ')
  386
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid time.']", f.clean, '   ')
394 387
 
395 388
     # DateTimeField ###############################################################
396 389
 
@@ -415,8 +408,8 @@ def test_datetimefield_1(self):
415 408
         self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30), f.clean('10/25/06 14:30:00'))
416 409
         self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30), f.clean('10/25/06 14:30'))
417 410
         self.assertEqual(datetime.datetime(2006, 10, 25, 0, 0), f.clean('10/25/06'))
418  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, 'hello')
419  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '2006-10-25 4:30 p.m.')
  411
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, 'hello')
  412
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '2006-10-25 4:30 p.m.')
420 413
 
421 414
     def test_datetimefield_2(self):
422 415
         f = DateTimeField(input_formats=['%Y %m %d %I:%M %p'])
@@ -425,7 +418,7 @@ def test_datetimefield_2(self):
425 418
         self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 59), f.clean(datetime.datetime(2006, 10, 25, 14, 30, 59)))
426 419
         self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 59, 200), f.clean(datetime.datetime(2006, 10, 25, 14, 30, 59, 200)))
427 420
         self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30), f.clean('2006 10 25 2:30 PM'))
428  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '2006-10-25 14:30:45')
  421
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '2006-10-25 14:30:45')
429 422
 
430 423
     def test_datetimefield_3(self):
431 424
         f = DateTimeField(required=False)
@@ -444,7 +437,7 @@ def test_datetimefield_4(self):
444 437
         self.assertEqual(datetime.datetime(2006, 10, 25, 0, 0), f.clean(' 10/25/2006 '))
445 438
         self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 45), f.clean(' 10/25/06 14:30:45 '))
446 439
         self.assertEqual(datetime.datetime(2006, 10, 25, 0, 0), f.clean(' 10/25/06 '))
447  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '   ')
  440
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '   ')
448 441
 
449 442
     # RegexField ##################################################################
450 443
 
@@ -452,65 +445,65 @@ def test_regexfield_1(self):
452 445
         f = RegexField('^\d[A-F]\d$')
453 446
         self.assertEqual(u'2A2', f.clean('2A2'))
454 447
         self.assertEqual(u'3F3', f.clean('3F3'))
455  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '3G3')
456  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, ' 2A2')
457  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '2A2 ')
458  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  448
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '3G3')
  449
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, ' 2A2')
  450
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '2A2 ')
  451
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
459 452
 
460 453
     def test_regexfield_2(self):
461 454
         f = RegexField('^\d[A-F]\d$', required=False)
462 455
         self.assertEqual(u'2A2', f.clean('2A2'))
463 456
         self.assertEqual(u'3F3', f.clean('3F3'))
464  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '3G3')
  457
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '3G3')
465 458
         self.assertEqual(u'', f.clean(''))
466 459
 
467 460
     def test_regexfield_3(self):
468 461
         f = RegexField(re.compile('^\d[A-F]\d$'))
469 462
         self.assertEqual(u'2A2', f.clean('2A2'))
470 463
         self.assertEqual(u'3F3', f.clean('3F3'))
471  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '3G3')
472  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, ' 2A2')
473  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '2A2 ')
  464
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '3G3')
  465
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, ' 2A2')
  466
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '2A2 ')
474 467
 
475 468
     def test_regexfield_4(self):
476 469
         f = RegexField('^\d\d\d\d$', error_message='Enter a four-digit number.')
477 470
         self.assertEqual(u'1234', f.clean('1234'))
478  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a four-digit number.']", f.clean, '123')
479  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a four-digit number.']", f.clean, 'abcd')
  471
+        self.assertRaisesMessage(ValidationError, "[u'Enter a four-digit number.']", f.clean, '123')
  472
+        self.assertRaisesMessage(ValidationError, "[u'Enter a four-digit number.']", f.clean, 'abcd')
480 473
 
481 474
     def test_regexfield_5(self):
482 475
         f = RegexField('^\d+$', min_length=5, max_length=10)
483  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at least 5 characters (it has 3).']", f.clean, '123')
484  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at least 5 characters (it has 3).', u'Enter a valid value.']", f.clean, 'abc')
  476
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at least 5 characters (it has 3).']", f.clean, '123')
  477
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at least 5 characters (it has 3).', u'Enter a valid value.']", f.clean, 'abc')
485 478
         self.assertEqual(u'12345', f.clean('12345'))
486 479
         self.assertEqual(u'1234567890', f.clean('1234567890'))
487  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at most 10 characters (it has 11).']", f.clean, '12345678901')
488  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '12345a')
  480
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at most 10 characters (it has 11).']", f.clean, '12345678901')
  481
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '12345a')
489 482
 
490 483
     # EmailField ##################################################################
491 484
 
492 485
     def test_emailfield_1(self):
493 486
         f = EmailField()
494  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
495  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  487
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  488
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
496 489
         self.assertEqual(u'person@example.com', f.clean('person@example.com'))
497  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo')
498  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@')
499  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@bar')
500  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@invalid-.com')
501  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@-invalid.com')
502  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@inv-.alid-.com')
503  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@inv-.-alid.com')
  490
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo')
  491
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@')
  492
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@bar')
  493
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@invalid-.com')
  494
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@-invalid.com')
  495
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@inv-.alid-.com')
  496
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@inv-.-alid.com')
504 497
         self.assertEqual(u'example@valid-----hyphens.com', f.clean('example@valid-----hyphens.com'))
505 498
         self.assertEqual(u'example@valid-with-hyphens.com', f.clean('example@valid-with-hyphens.com'))
506  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@.com')
  499
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@.com')
507 500
         self.assertEqual(u'local@domain.with.idn.xyz\xe4\xf6\xfc\xdfabc.part.com', f.clean('local@domain.with.idn.xyzäöüßabc.part.com'))
508 501
 
509 502
     def test_email_regexp_for_performance(self):
510 503
         f = EmailField()
511 504
         # Check for runaway regex security problem. This will take for-freeking-ever
512 505
         # if the security fix isn't in place.
513  
-        self.assertRaisesErrorWithMessage(
  506
+        self.assertRaisesMessage(
514 507
                 ValidationError,
515 508
                 "[u'Enter a valid e-mail address.']",
516 509
                 f.clean,
@@ -523,39 +516,39 @@ def test_emailfield_2(self):
523 516
         self.assertEqual(u'', f.clean(None))
524 517
         self.assertEqual(u'person@example.com', f.clean('person@example.com'))
525 518
         self.assertEqual(u'example@example.com', f.clean('      example@example.com  \t   \t '))
526  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo')
527  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@')
528  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@bar')
  519
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo')
  520
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@')
  521
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@bar')
529 522
 
530 523
     def test_emailfield_3(self):
531 524
         f = EmailField(min_length=10, max_length=15)
532  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at least 10 characters (it has 9).']", f.clean, 'a@foo.com')
  525
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at least 10 characters (it has 9).']", f.clean, 'a@foo.com')
533 526
         self.assertEqual(u'alf@foo.com', f.clean('alf@foo.com'))
534  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at most 15 characters (it has 20).']", f.clean, 'alf123456788@foo.com')
  527
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at most 15 characters (it has 20).']", f.clean, 'alf123456788@foo.com')
535 528
 
536 529
     # FileField ##################################################################
537 530
 
538 531
     def test_filefield_1(self):
539 532
         f = FileField()
540  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
541  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '', '')
  533
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  534
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '', '')
542 535
         self.assertEqual('files/test1.pdf', f.clean('', 'files/test1.pdf'))
543  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
544  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None, '')
  536
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  537
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None, '')
545 538
         self.assertEqual('files/test2.pdf', f.clean(None, 'files/test2.pdf'))
546  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'No file was submitted. Check the encoding type on the form.']", f.clean, SimpleUploadedFile('', ''))
547  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'No file was submitted. Check the encoding type on the form.']", f.clean, SimpleUploadedFile('', ''), '')
  539
+        self.assertRaisesMessage(ValidationError, "[u'No file was submitted. Check the encoding type on the form.']", f.clean, SimpleUploadedFile('', ''))
  540
+        self.assertRaisesMessage(ValidationError, "[u'No file was submitted. Check the encoding type on the form.']", f.clean, SimpleUploadedFile('', ''), '')
548 541
         self.assertEqual('files/test3.pdf', f.clean(None, 'files/test3.pdf'))
549  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'No file was submitted. Check the encoding type on the form.']", f.clean, 'some content that is not a file')
550  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'The submitted file is empty.']", f.clean, SimpleUploadedFile('name', None))
551  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'The submitted file is empty.']", f.clean, SimpleUploadedFile('name', ''))
  542
+        self.assertRaisesMessage(ValidationError, "[u'No file was submitted. Check the encoding type on the form.']", f.clean, 'some content that is not a file')
  543
+        self.assertRaisesMessage(ValidationError, "[u'The submitted file is empty.']", f.clean, SimpleUploadedFile('name', None))
  544
+        self.assertRaisesMessage(ValidationError, "[u'The submitted file is empty.']", f.clean, SimpleUploadedFile('name', ''))
552 545
         self.assertEqual(SimpleUploadedFile, type(f.clean(SimpleUploadedFile('name', 'Some File Content'))))
553 546
         self.assertEqual(SimpleUploadedFile, type(f.clean(SimpleUploadedFile('我隻氣墊船裝滿晒鱔.txt', 'मेरी मँडराने वाली नाव सर्पमीनों से भरी ह'))))
554 547
         self.assertEqual(SimpleUploadedFile, type(f.clean(SimpleUploadedFile('name', 'Some File Content'), 'files/test4.pdf')))
555 548
 
556 549
     def test_filefield_2(self):
557 550
         f = FileField(max_length = 5)
558  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this filename has at most 5 characters (it has 18).']", f.clean, SimpleUploadedFile('test_maxlength.txt', 'hello world'))
  551
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this filename has at most 5 characters (it has 18).']", f.clean, SimpleUploadedFile('test_maxlength.txt', 'hello world'))
559 552
         self.assertEqual('files/test1.pdf', f.clean('', 'files/test1.pdf'))
560 553
         self.assertEqual('files/test2.pdf', f.clean(None, 'files/test2.pdf'))
561 554
         self.assertEqual(SimpleUploadedFile, type(f.clean(SimpleUploadedFile('name', 'Some File Content'))))
@@ -569,8 +562,8 @@ def test_filefield_3(self):
569 562
 
570 563
     def test_urlfield_1(self):
571 564
         f = URLField()
572  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
573  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  565
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  566
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
574 567
         self.assertEqual(u'http://localhost/', f.clean('http://localhost'))
575 568
         self.assertEqual(u'http://example.com/', f.clean('http://example.com'))
576 569
         self.assertEqual(u'http://example.com./', f.clean('http://example.com.'))
@@ -580,17 +573,17 @@ def test_urlfield_1(self):
580 573
         self.assertEqual(u'http://subdomain.domain.com/', f.clean('subdomain.domain.com'))
581 574
         self.assertEqual(u'http://200.8.9.10/', f.clean('http://200.8.9.10'))
582 575
         self.assertEqual(u'http://200.8.9.10:8000/test', f.clean('http://200.8.9.10:8000/test'))
583  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'foo')
584  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://')
585  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example')
586  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example.')
587  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'com.')
588  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, '.')
589  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://.com')
590  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://invalid-.com')
591  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://-invalid.com')
592  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://inv-.alid-.com')
593  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://inv-.-alid.com')
  576
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'foo')
  577
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://')
  578
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example')
  579
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example.')
  580
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'com.')
  581
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, '.')
  582
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://.com')
  583
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://invalid-.com')
  584
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://-invalid.com')
  585
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://inv-.alid-.com')
  586
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://inv-.-alid.com')
594 587
         self.assertEqual(u'http://valid-----hyphens.com/', f.clean('http://valid-----hyphens.com'))
595 588
         self.assertEqual(u'http://some.idn.xyz\xe4\xf6\xfc\xdfabc.domain.com:123/blah', f.clean('http://some.idn.xyzäöüßabc.domain.com:123/blah'))
596 589
         self.assertEqual(u'http://www.example.com/s/http://code.djangoproject.com/ticket/13804', f.clean('www.example.com/s/http://code.djangoproject.com/ticket/13804'))
@@ -598,11 +591,11 @@ def test_urlfield_1(self):
598 591
     def test_url_regex_ticket11198(self):
599 592
         f = URLField()
600 593
         # hangs "forever" if catastrophic backtracking in ticket:#11198 not fixed
601  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://%s' % ("X"*200,))
  594
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://%s' % ("X"*200,))
602 595
 
603 596
         # a second test, to make sure the problem is really addressed, even on
604 597
         # domains that don't fail the domain label length check in the regex
605  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://%s' % ("X"*60,))
  598
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://%s' % ("X"*60,))
606 599
 
607 600
     def test_urlfield_2(self):
608 601
         f = URLField(required=False)
@@ -610,17 +603,17 @@ def test_urlfield_2(self):
610 603
         self.assertEqual(u'', f.clean(None))
611 604
         self.assertEqual(u'http://example.com/', f.clean('http://example.com'))
612 605
         self.assertEqual(u'http://www.example.com/', f.clean('http://www.example.com'))
613  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'foo')
614  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://')
615  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example')
616  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example.')
617  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://.com')
  606
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'foo')
  607
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://')
  608
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example')
  609
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example.')
  610
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://.com')
618 611
 
619 612
     @verify_exists_urls(('http://www.google.com/',))
620 613
     def test_urlfield_3(self):
621 614
         f = URLField(verify_exists=True)
622 615
         self.assertEqual(u'http://www.google.com/', f.clean('http://www.google.com'))
623  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example')
  616
+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example')
624 617
         self.assertRaises(ValidationError, f.clean, 'http://www.broken.djangoproject.com') # bad domain
625 618
         self.assertRaises(ValidationError, f.clean, 'http://qa-dev.w3.org/link-testsuite/http.php?code=405') # Method not allowed
626 619
         try:
@@ -641,9 +634,9 @@ def test_urlfield_4(self):
641 634
 
642 635
     def test_urlfield_5(self):
643 636
         f = URLField(min_length=15, max_length=20)
644  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at least 15 characters (it has 13).']", f.clean, 'http://f.com')
  637
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at least 15 characters (it has 13).']", f.clean, 'http://f.com')
645 638
         self.assertEqual(u'http://example.com/', f.clean('http://example.com'))
646  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at most 20 characters (it has 38).']", f.clean, 'http://abcdefghijklmnopqrstuvwxyz.com')
  639
+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at most 20 characters (it has 38).']", f.clean, 'http://abcdefghijklmnopqrstuvwxyz.com')
647 640
 
648 641
     def test_urlfield_6(self):
649 642
         f = URLField(required=False)
@@ -697,15 +690,15 @@ def test_urlfield_10(self):
697 690
 
698 691
     def test_booleanfield_1(self):
699 692
         f = BooleanField()
700  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
701  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  693
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  694
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
702 695
         self.assertEqual(True, f.clean(True))
703  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, False)
  696
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, False)
704 697
         self.assertEqual(True, f.clean(1))
705  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, 0)
  698
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, 0)
706 699
         self.assertEqual(True, f.clean('Django rocks'))
707 700
         self.assertEqual(True, f.clean('True'))
708  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, 'False')
  701
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, 'False')
709 702
 
710 703
     def test_booleanfield_2(self):
711 704
         f = BooleanField(required=False)
@@ -726,11 +719,11 @@ def test_booleanfield_2(self):
726 719
 
727 720
     def test_choicefield_1(self):
728 721
         f = ChoiceField(choices=[('1', 'One'), ('2', 'Two')])
729  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
730  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  722
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  723
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
731 724
         self.assertEqual(u'1', f.clean(1))
732 725
         self.assertEqual(u'1', f.clean('1'))
733  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, '3')
  726
+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, '3')
734 727
 
735 728
     def test_choicefield_2(self):
736 729
         f = ChoiceField(choices=[('1', 'One'), ('2', 'Two')], required=False)
@@ -738,12 +731,12 @@ def test_choicefield_2(self):
738 731
         self.assertEqual(u'', f.clean(None))
739 732
         self.assertEqual(u'1', f.clean(1))
740 733
         self.assertEqual(u'1', f.clean('1'))
741  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, '3')
  734
+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, '3')
742 735
 
743 736
     def test_choicefield_3(self):
744 737
         f = ChoiceField(choices=[('J', 'John'), ('P', 'Paul')])
745 738
         self.assertEqual(u'J', f.clean('J'))
746  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. John is not one of the available choices.']", f.clean, 'John')
  739
+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. John is not one of the available choices.']", f.clean, 'John')
747 740
 
748 741
     def test_choicefield_4(self):
749 742
         f = ChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3','A'),('4','B'))), ('5','Other')])
@@ -753,7 +746,7 @@ def test_choicefield_4(self):
753 746
         self.assertEqual(u'3', f.clean('3'))
754 747
         self.assertEqual(u'5', f.clean(5))
755 748
         self.assertEqual(u'5', f.clean('5'))
756  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 6 is not one of the available choices.']", f.clean, '6')
  749
+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 6 is not one of the available choices.']", f.clean, '6')
757 750
 
758 751
     # TypedChoiceField ############################################################
759 752
     # TypedChoiceField is just like ChoiceField, except that coerced types will
@@ -762,7 +755,7 @@ def test_choicefield_4(self):
762 755
     def test_typedchoicefield_1(self):
763 756
         f = TypedChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int)
764 757
         self.assertEqual(1, f.clean('1'))
765  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 2 is not one of the available choices.']", f.clean, '2')
  758
+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 2 is not one of the available choices.']", f.clean, '2')
766 759
 
767 760
     def test_typedchoicefield_2(self):
768 761
         # Different coercion, same validation.
@@ -778,9 +771,9 @@ def test_typedchoicefield_4(self):
778 771
         # Even more weirdness: if you have a valid choice but your coercion function
779 772
         # can't coerce, you'll still get a validation error. Don't do this!
780 773
         f = TypedChoiceField(choices=[('A', 'A'), ('B', 'B')], coerce=int)
781  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. B is not one of the available choices.']", f.clean, 'B')
  774
+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. B is not one of the available choices.']", f.clean, 'B')
782 775
         # Required fields require values
783  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  776
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
784 777
 
785 778
     def test_typedchoicefield_5(self):
786 779
         # Non-required fields aren't required
@@ -842,17 +835,17 @@ class MySQLNullBooleanForm(Form):
842 835
 
843 836
     def test_multiplechoicefield_1(self):
844 837
         f = MultipleChoiceField(choices=[('1', 'One'), ('2', 'Two')])
845  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
846  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
  838
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
  839
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
847 840
         self.assertEqual([u'1'], f.clean([1]))
848 841
         self.assertEqual([u'1'], f.clean(['1']))
849 842
         self.assertEqual([u'1', u'2'], f.clean(['1', '2']))
850 843
         self.assertEqual([u'1', u'2'], f.clean([1, '2']))
851 844
         self.assertEqual([u'1', u'2'], f.clean((1, '2')))
852  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a list of values.']", f.clean, 'hello')
853  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, [])
854  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, ())
855  
-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, ['3'])
  845
+        self.assertRaisesMessage(ValidationError, "[u'Enter a list of values.']", f.clean, 'hello')
  846
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, [])
  847
+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, ())
  848
+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, ['3'])
856 849
 
857 850
     def test_multiplechoicefield_2(self):
858 851
         f = MultipleChoiceField(choices=[('1', 'One'), ('2', 'Two')], required=False)
@@ -863,10 +856,10 @@ def test_multiplechoicefield_2(self):
863 856
         self.assertEqual([u'1', u'2'], f.clean(['1', '2']))
864