Code

Ticket #14503: 14503-with-testcase-class.diff

File 14503-with-testcase-class.diff, 70.4 KB (added by ramiro, 3 years ago)

Similar patch but using a thin subclass of django.utuls.unitest.TestCase

Line 
1diff --git a/django/test/__init__.py b/django/test/__init__.py
2--- a/django/test/__init__.py
3+++ b/django/test/__init__.py
4@@ -3,5 +3,6 @@
5 """
6 
7 from django.test.client import Client, RequestFactory
8-from django.test.testcases import TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature
9+from django.test.testcases import (TestCase, TransactionTestCase,
10+        skipIfDBFeature, skipUnlessDBFeature, SimpleTestCase)
11 from django.test.utils import Approximate
12diff --git a/django/test/testcases.py b/django/test/testcases.py
13--- a/django/test/testcases.py
14+++ b/django/test/testcases.py
15@@ -21,7 +21,7 @@
16 from django.utils.encoding import smart_str
17 
18 __all__ = ('DocTestRunner', 'OutputChecker', 'TestCase', 'TransactionTestCase',
19-           'skipIfDBFeature', 'skipUnlessDBFeature')
20+           'skipIfDBFeature', 'skipUnlessDBFeature', 'SimpleTestCase')
21 
22 normalize_long_ints = lambda s: re.sub(r'(?<![\w])(\d+)L(?![\w])', '\\1', s)
23 normalize_decimals = lambda s: re.sub(r"Decimal\('(\d+(\.\d*)?)'\)", lambda m: "Decimal(\"%s\")" % m.groups()[0], s)
24@@ -235,8 +235,23 @@
25             )
26         )
27 
28+class SimpleTestCase(ut2.TestCase):
29 
30-class TransactionTestCase(ut2.TestCase):
31+    def assertRaisesMessage(self, expected_exception, expected_message,
32+                           callable_obj=None, *args, **kwargs):
33+        """Asserts that the message in a raised exception matches the passe value.
34+
35+        Args:
36+            expected_exception: Exception class expected to be raised.
37+            expected_message: expected error message string value.
38+            callable_obj: Function to be called.
39+            args: Extra args.
40+            kwargs: Extra kwargs.
41+        """
42+        return self.assertRaisesRegexp(expected_exception,
43+                re.escape(expected_message), callable_obj, *args, **kwargs)
44+
45+class TransactionTestCase(SimpleTestCase):
46     # The class we'll use for the test client self.client.
47     # Can be overridden in derived classes.
48     client_class = Client
49diff --git a/tests/regressiontests/admin_validation/tests.py b/tests/regressiontests/admin_validation/tests.py
50--- a/tests/regressiontests/admin_validation/tests.py
51+++ b/tests/regressiontests/admin_validation/tests.py
52@@ -19,12 +19,6 @@
53     fields = ['spam']
54 
55 class ValidationTestCase(TestCase):
56-    def assertRaisesMessage(self, exc, msg, func, *args, **kwargs):
57-        try:
58-            func(*args, **kwargs)
59-        except Exception, e:
60-            self.assertEqual(msg, str(e))
61-            self.assertTrue(isinstance(e, exc), "Expected %s, got %s" % (exc, type(e)))
62 
63     def test_readonly_and_editable(self):
64         class SongAdmin(admin.ModelAdmin):
65diff --git a/tests/regressiontests/custom_columns_regress/tests.py b/tests/regressiontests/custom_columns_regress/tests.py
66--- a/tests/regressiontests/custom_columns_regress/tests.py
67+++ b/tests/regressiontests/custom_columns_regress/tests.py
68@@ -9,13 +9,6 @@
69 
70 class CustomColumnRegression(TestCase):
71 
72-    def assertRaisesMessage(self, exc, msg, func, *args, **kwargs):
73-        try:
74-            func(*args, **kwargs)
75-        except Exception, e:
76-            self.assertEqual(msg, str(e))
77-            self.assertTrue(isinstance(e, exc), "Expected %s, got %s" % (exc, type(e)))
78-
79     def setUp(self):
80         self.a1 = Author.objects.create(first_name='John', last_name='Smith')
81         self.a2 = Author.objects.create(first_name='Peter', last_name='Jones')
82diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py
83--- a/tests/regressiontests/file_storage/tests.py
84+++ b/tests/regressiontests/file_storage/tests.py
85@@ -22,6 +22,7 @@
86 from django.core.files.images import get_image_dimensions
87 from django.core.files.storage import FileSystemStorage, get_storage_class
88 from django.core.files.uploadedfile import UploadedFile
89+from django.test import SimpleTestCase
90 from django.utils import unittest
91 
92 # Try to import PIL in either of the two ways it can end up installed.
93@@ -36,14 +37,7 @@
94         Image = None
95 
96 
97-class GetStorageClassTests(unittest.TestCase):
98-    def assertRaisesErrorWithMessage(self, error, message, callable,
99-        *args, **kwargs):
100-        self.assertRaises(error, callable, *args, **kwargs)
101-        try:
102-            callable(*args, **kwargs)
103-        except error, e:
104-            self.assertEqual(message, str(e))
105+class GetStorageClassTests(SimpleTestCase):
106 
107     def test_get_filesystem_storage(self):
108         """
109@@ -57,7 +51,7 @@
110         """
111         get_storage_class raises an error if the requested import don't exist.
112         """
113-        self.assertRaisesErrorWithMessage(
114+        self.assertRaisesMessage(
115             ImproperlyConfigured,
116             "NonExistingStorage isn't a storage module.",
117             get_storage_class,
118@@ -67,7 +61,7 @@
119         """
120         get_storage_class raises an error if the requested class don't exist.
121         """
122-        self.assertRaisesErrorWithMessage(
123+        self.assertRaisesMessage(
124             ImproperlyConfigured,
125             'Storage module "django.core.files.storage" does not define a '\
126                 '"NonExistingStorage" class.',
127diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py
128--- a/tests/regressiontests/fixtures_regress/tests.py
129+++ b/tests/regressiontests/fixtures_regress/tests.py
130@@ -393,12 +393,6 @@
131 
132 
133 class NaturalKeyFixtureTests(TestCase):
134-    def assertRaisesMessage(self, exc, msg, func, *args, **kwargs):
135-        try:
136-            func(*args, **kwargs)
137-        except Exception, e:
138-            self.assertEqual(msg, str(e))
139-            self.assertTrue(isinstance(e, exc), "Expected %s, got %s" % (exc, type(e)))
140 
141     def test_nk_deserialize(self):
142         """
143diff --git a/tests/regressiontests/forms/tests/fields.py b/tests/regressiontests/forms/tests/fields.py
144--- a/tests/regressiontests/forms/tests/fields.py
145+++ b/tests/regressiontests/forms/tests/fields.py
146@@ -33,7 +33,7 @@
147 
148 from django.core.files.uploadedfile import SimpleUploadedFile
149 from django.forms import *
150-from django.utils.unittest import TestCase
151+from django.test import SimpleTestCase
152 
153 
154 def fix_os_paths(x):
155@@ -69,14 +69,7 @@
156     return decorator
157 
158 
159-class FieldsTests(TestCase):
160-
161-    def assertRaisesErrorWithMessage(self, error, message, callable, *args, **kwargs):
162-        self.assertRaises(error, callable, *args, **kwargs)
163-        try:
164-            callable(*args, **kwargs)
165-        except error, e:
166-            self.assertEqual(message, str(e))
167+class FieldsTests(SimpleTestCase):
168 
169     def test_field_sets_widget_is_required(self):
170         self.assertTrue(Field(required=True).widget.is_required)
171@@ -88,8 +81,8 @@
172         f = CharField()
173         self.assertEqual(u'1', f.clean(1))
174         self.assertEqual(u'hello', f.clean('hello'))
175-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
176-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
177+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
178+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
179         self.assertEqual(u'[1, 2, 3]', f.clean([1, 2, 3]))
180         self.assertEqual(f.max_length, None)
181         self.assertEqual(f.min_length, None)
182@@ -108,14 +101,14 @@
183         f = CharField(max_length=10, required=False)
184         self.assertEqual(u'12345', f.clean('12345'))
185         self.assertEqual(u'1234567890', f.clean('1234567890'))
186-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at most 10 characters (it has 11).']", f.clean, '1234567890a')
187+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at most 10 characters (it has 11).']", f.clean, '1234567890a')
188         self.assertEqual(f.max_length, 10)
189         self.assertEqual(f.min_length, None)
190 
191     def test_charfield_4(self):
192         f = CharField(min_length=10, required=False)
193         self.assertEqual(u'', f.clean(''))
194-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at least 10 characters (it has 5).']", f.clean, '12345')
195+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at least 10 characters (it has 5).']", f.clean, '12345')
196         self.assertEqual(u'1234567890', f.clean('1234567890'))
197         self.assertEqual(u'1234567890a', f.clean('1234567890a'))
198         self.assertEqual(f.max_length, None)
199@@ -123,8 +116,8 @@
200 
201     def test_charfield_5(self):
202         f = CharField(min_length=10, required=True)
203-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
204-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at least 10 characters (it has 5).']", f.clean, '12345')
205+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
206+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at least 10 characters (it has 5).']", f.clean, '12345')
207         self.assertEqual(u'1234567890', f.clean('1234567890'))
208         self.assertEqual(u'1234567890a', f.clean('1234567890a'))
209         self.assertEqual(f.max_length, None)
210@@ -134,18 +127,18 @@
211 
212     def test_integerfield_1(self):
213         f = IntegerField()
214-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
215-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
216+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
217+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
218         self.assertEqual(1, f.clean('1'))
219         self.assertEqual(True, isinstance(f.clean('1'), int))
220         self.assertEqual(23, f.clean('23'))
221-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a whole number.']", f.clean, 'a')
222+        self.assertRaisesMessage(ValidationError, "[u'Enter a whole number.']", f.clean, 'a')
223         self.assertEqual(42, f.clean(42))
224-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a whole number.']", f.clean, 3.14)
225+        self.assertRaisesMessage(ValidationError, "[u'Enter a whole number.']", f.clean, 3.14)
226         self.assertEqual(1, f.clean('1 '))
227         self.assertEqual(1, f.clean(' 1'))
228         self.assertEqual(1, f.clean(' 1 '))
229-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a whole number.']", f.clean, '1a')
230+        self.assertRaisesMessage(ValidationError, "[u'Enter a whole number.']", f.clean, '1a')
231         self.assertEqual(f.max_value, None)
232         self.assertEqual(f.min_value, None)
233 
234@@ -158,29 +151,29 @@
235         self.assertEqual(1, f.clean('1'))
236         self.assertEqual(True, isinstance(f.clean('1'), int))
237         self.assertEqual(23, f.clean('23'))
238-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a whole number.']", f.clean, 'a')
239+        self.assertRaisesMessage(ValidationError, "[u'Enter a whole number.']", f.clean, 'a')
240         self.assertEqual(1, f.clean('1 '))
241         self.assertEqual(1, f.clean(' 1'))
242         self.assertEqual(1, f.clean(' 1 '))
243-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a whole number.']", f.clean, '1a')
244+        self.assertRaisesMessage(ValidationError, "[u'Enter a whole number.']", f.clean, '1a')
245         self.assertEqual(f.max_value, None)
246         self.assertEqual(f.min_value, None)
247 
248     def test_integerfield_3(self):
249         f = IntegerField(max_value=10)
250-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
251+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
252         self.assertEqual(1, f.clean(1))
253         self.assertEqual(10, f.clean(10))
254-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is less than or equal to 10.']", f.clean, 11)
255+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is less than or equal to 10.']", f.clean, 11)
256         self.assertEqual(10, f.clean('10'))
257-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is less than or equal to 10.']", f.clean, '11')
258+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is less than or equal to 10.']", f.clean, '11')
259         self.assertEqual(f.max_value, 10)
260         self.assertEqual(f.min_value, None)
261 
262     def test_integerfield_4(self):
263         f = IntegerField(min_value=10)
264-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
265-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is greater than or equal to 10.']", f.clean, 1)
266+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
267+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is greater than or equal to 10.']", f.clean, 1)
268         self.assertEqual(10, f.clean(10))
269         self.assertEqual(11, f.clean(11))
270         self.assertEqual(10, f.clean('10'))
271@@ -190,14 +183,14 @@
272 
273     def test_integerfield_5(self):
274         f = IntegerField(min_value=10, max_value=20)
275-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
276-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is greater than or equal to 10.']", f.clean, 1)
277+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
278+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is greater than or equal to 10.']", f.clean, 1)
279         self.assertEqual(10, f.clean(10))
280         self.assertEqual(11, f.clean(11))
281         self.assertEqual(10, f.clean('10'))
282         self.assertEqual(11, f.clean('11'))
283         self.assertEqual(20, f.clean(20))
284-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is less than or equal to 20.']", f.clean, 21)
285+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is less than or equal to 20.']", f.clean, 21)
286         self.assertEqual(f.max_value, 20)
287         self.assertEqual(f.min_value, 10)
288 
289@@ -205,19 +198,19 @@
290 
291     def test_floatfield_1(self):
292         f = FloatField()
293-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
294-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
295+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
296+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
297         self.assertEqual(1.0, f.clean('1'))
298         self.assertEqual(True, isinstance(f.clean('1'), float))
299         self.assertEqual(23.0, f.clean('23'))
300         self.assertEqual(3.1400000000000001, f.clean('3.14'))
301         self.assertEqual(3.1400000000000001, f.clean(3.14))
302         self.assertEqual(42.0, f.clean(42))
303-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, 'a')
304+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, 'a')
305         self.assertEqual(1.0, f.clean('1.0 '))
306         self.assertEqual(1.0, f.clean(' 1.0'))
307         self.assertEqual(1.0, f.clean(' 1.0 '))
308-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, '1.0a')
309+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, '1.0a')
310         self.assertEqual(f.max_value, None)
311         self.assertEqual(f.min_value, None)
312 
313@@ -231,8 +224,8 @@
314 
315     def test_floatfield_3(self):
316         f = FloatField(max_value=1.5, min_value=0.5)
317-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is less than or equal to 1.5.']", f.clean, '1.6')
318-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is greater than or equal to 0.5.']", f.clean, '0.4')
319+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is less than or equal to 1.5.']", f.clean, '1.6')
320+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is greater than or equal to 0.5.']", f.clean, '0.4')
321         self.assertEqual(1.5, f.clean('1.5'))
322         self.assertEqual(0.5, f.clean('0.5'))
323         self.assertEqual(f.max_value, 1.5)
324@@ -242,34 +235,34 @@
325 
326     def test_decimalfield_1(self):
327         f = DecimalField(max_digits=4, decimal_places=2)
328-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
329-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
330+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
331+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
332         self.assertEqual(f.clean('1'), Decimal("1"))
333         self.assertEqual(True, isinstance(f.clean('1'), Decimal))
334         self.assertEqual(f.clean('23'), Decimal("23"))
335         self.assertEqual(f.clean('3.14'), Decimal("3.14"))
336         self.assertEqual(f.clean(3.14), Decimal("3.14"))
337         self.assertEqual(f.clean(Decimal('3.14')), Decimal("3.14"))
338-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, 'NaN')
339-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, 'Inf')
340-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, '-Inf')
341-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, 'a')
342-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, u'łąść')
343+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, 'NaN')
344+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, 'Inf')
345+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, '-Inf')
346+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, 'a')
347+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, u'łąść')
348         self.assertEqual(f.clean('1.0 '), Decimal("1.0"))
349         self.assertEqual(f.clean(' 1.0'), Decimal("1.0"))
350         self.assertEqual(f.clean(' 1.0 '), Decimal("1.0"))
351-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, '1.0a')
352-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 4 digits in total.']", f.clean, '123.45')
353-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 2 decimal places.']", f.clean, '1.234')
354-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 2 digits before the decimal point.']", f.clean, '123.4')
355+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, '1.0a')
356+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 4 digits in total.']", f.clean, '123.45')
357+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 2 decimal places.']", f.clean, '1.234')
358+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 2 digits before the decimal point.']", f.clean, '123.4')
359         self.assertEqual(f.clean('-12.34'), Decimal("-12.34"))
360-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 4 digits in total.']", f.clean, '-123.45')
361+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 4 digits in total.']", f.clean, '-123.45')
362         self.assertEqual(f.clean('-.12'), Decimal("-0.12"))
363         self.assertEqual(f.clean('-00.12'), Decimal("-0.12"))
364         self.assertEqual(f.clean('-000.12'), Decimal("-0.12"))
365-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 2 decimal places.']", f.clean, '-000.123')
366-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 4 digits in total.']", f.clean, '-000.12345')
367-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a number.']", f.clean, '--0.12')
368+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 2 decimal places.']", f.clean, '-000.123')
369+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 4 digits in total.']", f.clean, '-000.12345')
370+        self.assertRaisesMessage(ValidationError, "[u'Enter a number.']", f.clean, '--0.12')
371         self.assertEqual(f.max_digits, 4)
372         self.assertEqual(f.decimal_places, 2)
373         self.assertEqual(f.max_value, None)
374@@ -287,8 +280,8 @@
375 
376     def test_decimalfield_3(self):
377         f = DecimalField(max_digits=4, decimal_places=2, max_value=Decimal('1.5'), min_value=Decimal('0.5'))
378-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is less than or equal to 1.5.']", f.clean, '1.6')
379-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value is greater than or equal to 0.5.']", f.clean, '0.4')
380+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is less than or equal to 1.5.']", f.clean, '1.6')
381+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value is greater than or equal to 0.5.']", f.clean, '0.4')
382         self.assertEqual(f.clean('1.5'), Decimal("1.5"))
383         self.assertEqual(f.clean('0.5'), Decimal("0.5"))
384         self.assertEqual(f.clean('.5'), Decimal("0.5"))
385@@ -300,7 +293,7 @@
386 
387     def test_decimalfield_4(self):
388         f = DecimalField(decimal_places=2)
389-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 2 decimal places.']", f.clean, '0.00000001')
390+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 2 decimal places.']", f.clean, '0.00000001')
391 
392     def test_decimalfield_5(self):
393         f = DecimalField(max_digits=3)
394@@ -310,13 +303,13 @@
395         self.assertEqual(f.clean('0000000.100'), Decimal("0.100"))
396         # Only leading whole zeros "collapse" to one digit.
397         self.assertEqual(f.clean('000000.02'), Decimal('0.02'))
398-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 3 digits in total.']", f.clean, '000000.0002')
399+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 3 digits in total.']", f.clean, '000000.0002')
400         self.assertEqual(f.clean('.002'), Decimal("0.002"))
401 
402     def test_decimalfield_6(self):
403         f = DecimalField(max_digits=2, decimal_places=2)
404         self.assertEqual(f.clean('.01'), Decimal(".01"))
405-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure that there are no more than 0 digits before the decimal point.']", f.clean, '1.1')
406+        self.assertRaisesMessage(ValidationError, "[u'Ensure that there are no more than 0 digits before the decimal point.']", f.clean, '1.1')
407 
408     # DateField ###################################################################
409 
410@@ -334,10 +327,10 @@
411         self.assertEqual(datetime.date(2006, 10, 25), f.clean('October 25, 2006'))
412         self.assertEqual(datetime.date(2006, 10, 25), f.clean('25 October 2006'))
413         self.assertEqual(datetime.date(2006, 10, 25), f.clean('25 October, 2006'))
414-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '2006-4-31')
415-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '200a-10-25')
416-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '25/10/06')
417-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
418+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '2006-4-31')
419+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '200a-10-25')
420+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '25/10/06')
421+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
422 
423     def test_datefield_2(self):
424         f = DateField(required=False)
425@@ -351,9 +344,9 @@
426         self.assertEqual(datetime.date(2006, 10, 25), f.clean(datetime.date(2006, 10, 25)))
427         self.assertEqual(datetime.date(2006, 10, 25), f.clean(datetime.datetime(2006, 10, 25, 14, 30)))
428         self.assertEqual(datetime.date(2006, 10, 25), f.clean('2006 10 25'))
429-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '2006-10-25')
430-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '10/25/2006')
431-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '10/25/06')
432+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '2006-10-25')
433+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '10/25/2006')
434+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '10/25/06')
435 
436     def test_datefield_4(self):
437         # Test whitespace stripping behavior (#5714)
438@@ -364,7 +357,7 @@
439         self.assertEqual(datetime.date(2006, 10, 25), f.clean(' October  25 2006 '))
440         self.assertEqual(datetime.date(2006, 10, 25), f.clean(' October 25, 2006 '))
441         self.assertEqual(datetime.date(2006, 10, 25), f.clean(' 25 October 2006 '))
442-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '   ')
443+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, '   ')
444 
445     # TimeField ###################################################################
446 
447@@ -374,8 +367,8 @@
448         self.assertEqual(datetime.time(14, 25, 59), f.clean(datetime.time(14, 25, 59)))
449         self.assertEqual(datetime.time(14, 25), f.clean('14:25'))
450         self.assertEqual(datetime.time(14, 25, 59), f.clean('14:25:59'))
451-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid time.']", f.clean, 'hello')
452-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid time.']", f.clean, '1:24 p.m.')
453+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid time.']", f.clean, 'hello')
454+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid time.']", f.clean, '1:24 p.m.')
455 
456     def test_timefield_2(self):
457         f = TimeField(input_formats=['%I:%M %p'])
458@@ -383,14 +376,14 @@
459         self.assertEqual(datetime.time(14, 25, 59), f.clean(datetime.time(14, 25, 59)))
460         self.assertEqual(datetime.time(4, 25), f.clean('4:25 AM'))
461         self.assertEqual(datetime.time(16, 25), f.clean('4:25 PM'))
462-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid time.']", f.clean, '14:30:45')
463+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid time.']", f.clean, '14:30:45')
464 
465     def test_timefield_3(self):
466         f = TimeField()
467         # Test whitespace stripping behavior (#5714)
468         self.assertEqual(datetime.time(14, 25), f.clean(' 14:25 '))
469         self.assertEqual(datetime.time(14, 25, 59), f.clean(' 14:25:59 '))
470-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid time.']", f.clean, '   ')
471+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid time.']", f.clean, '   ')
472 
473     # DateTimeField ###############################################################
474 
475@@ -415,8 +408,8 @@
476         self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30), f.clean('10/25/06 14:30:00'))
477         self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30), f.clean('10/25/06 14:30'))
478         self.assertEqual(datetime.datetime(2006, 10, 25, 0, 0), f.clean('10/25/06'))
479-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, 'hello')
480-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '2006-10-25 4:30 p.m.')
481+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, 'hello')
482+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '2006-10-25 4:30 p.m.')
483 
484     def test_datetimefield_2(self):
485         f = DateTimeField(input_formats=['%Y %m %d %I:%M %p'])
486@@ -425,7 +418,7 @@
487         self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 59), f.clean(datetime.datetime(2006, 10, 25, 14, 30, 59)))
488         self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 59, 200), f.clean(datetime.datetime(2006, 10, 25, 14, 30, 59, 200)))
489         self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30), f.clean('2006 10 25 2:30 PM'))
490-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '2006-10-25 14:30:45')
491+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '2006-10-25 14:30:45')
492 
493     def test_datetimefield_3(self):
494         f = DateTimeField(required=False)
495@@ -444,7 +437,7 @@
496         self.assertEqual(datetime.datetime(2006, 10, 25, 0, 0), f.clean(' 10/25/2006 '))
497         self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 45), f.clean(' 10/25/06 14:30:45 '))
498         self.assertEqual(datetime.datetime(2006, 10, 25, 0, 0), f.clean(' 10/25/06 '))
499-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '   ')
500+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '   ')
501 
502     # RegexField ##################################################################
503 
504@@ -452,65 +445,65 @@
505         f = RegexField('^\d[A-F]\d$')
506         self.assertEqual(u'2A2', f.clean('2A2'))
507         self.assertEqual(u'3F3', f.clean('3F3'))
508-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '3G3')
509-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, ' 2A2')
510-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '2A2 ')
511-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
512+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '3G3')
513+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, ' 2A2')
514+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '2A2 ')
515+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
516 
517     def test_regexfield_2(self):
518         f = RegexField('^\d[A-F]\d$', required=False)
519         self.assertEqual(u'2A2', f.clean('2A2'))
520         self.assertEqual(u'3F3', f.clean('3F3'))
521-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '3G3')
522+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '3G3')
523         self.assertEqual(u'', f.clean(''))
524 
525     def test_regexfield_3(self):
526         f = RegexField(re.compile('^\d[A-F]\d$'))
527         self.assertEqual(u'2A2', f.clean('2A2'))
528         self.assertEqual(u'3F3', f.clean('3F3'))
529-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '3G3')
530-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, ' 2A2')
531-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '2A2 ')
532+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '3G3')
533+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, ' 2A2')
534+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '2A2 ')
535 
536     def test_regexfield_4(self):
537         f = RegexField('^\d\d\d\d$', error_message='Enter a four-digit number.')
538         self.assertEqual(u'1234', f.clean('1234'))
539-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a four-digit number.']", f.clean, '123')
540-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a four-digit number.']", f.clean, 'abcd')
541+        self.assertRaisesMessage(ValidationError, "[u'Enter a four-digit number.']", f.clean, '123')
542+        self.assertRaisesMessage(ValidationError, "[u'Enter a four-digit number.']", f.clean, 'abcd')
543 
544     def test_regexfield_5(self):
545         f = RegexField('^\d+$', min_length=5, max_length=10)
546-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at least 5 characters (it has 3).']", f.clean, '123')
547-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at least 5 characters (it has 3).', u'Enter a valid value.']", f.clean, 'abc')
548+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at least 5 characters (it has 3).']", f.clean, '123')
549+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at least 5 characters (it has 3).', u'Enter a valid value.']", f.clean, 'abc')
550         self.assertEqual(u'12345', f.clean('12345'))
551         self.assertEqual(u'1234567890', f.clean('1234567890'))
552-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at most 10 characters (it has 11).']", f.clean, '12345678901')
553-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '12345a')
554+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at most 10 characters (it has 11).']", f.clean, '12345678901')
555+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid value.']", f.clean, '12345a')
556 
557     # EmailField ##################################################################
558 
559     def test_emailfield_1(self):
560         f = EmailField()
561-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
562-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
563+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
564+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
565         self.assertEqual(u'person@example.com', f.clean('person@example.com'))
566-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo')
567-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@')
568-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@bar')
569-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@invalid-.com')
570-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@-invalid.com')
571-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@inv-.alid-.com')
572-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@inv-.-alid.com')
573+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo')
574+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@')
575+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@bar')
576+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@invalid-.com')
577+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@-invalid.com')
578+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@inv-.alid-.com')
579+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@inv-.-alid.com')
580         self.assertEqual(u'example@valid-----hyphens.com', f.clean('example@valid-----hyphens.com'))
581         self.assertEqual(u'example@valid-with-hyphens.com', f.clean('example@valid-with-hyphens.com'))
582-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@.com')
583+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'example@.com')
584         self.assertEqual(u'local@domain.with.idn.xyz\xe4\xf6\xfc\xdfabc.part.com', f.clean('local@domain.with.idn.xyzäöüßabc.part.com'))
585 
586     def test_email_regexp_for_performance(self):
587         f = EmailField()
588         # Check for runaway regex security problem. This will take for-freeking-ever
589         # if the security fix isn't in place.
590-        self.assertRaisesErrorWithMessage(
591+        self.assertRaisesMessage(
592                 ValidationError,
593                 "[u'Enter a valid e-mail address.']",
594                 f.clean,
595@@ -523,39 +516,39 @@
596         self.assertEqual(u'', f.clean(None))
597         self.assertEqual(u'person@example.com', f.clean('person@example.com'))
598         self.assertEqual(u'example@example.com', f.clean('      example@example.com  \t   \t '))
599-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo')
600-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@')
601-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@bar')
602+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo')
603+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@')
604+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@bar')
605 
606     def test_emailfield_3(self):
607         f = EmailField(min_length=10, max_length=15)
608-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at least 10 characters (it has 9).']", f.clean, 'a@foo.com')
609+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at least 10 characters (it has 9).']", f.clean, 'a@foo.com')
610         self.assertEqual(u'alf@foo.com', f.clean('alf@foo.com'))
611-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at most 15 characters (it has 20).']", f.clean, 'alf123456788@foo.com')
612+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at most 15 characters (it has 20).']", f.clean, 'alf123456788@foo.com')
613 
614     # FileField ##################################################################
615 
616     def test_filefield_1(self):
617         f = FileField()
618-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
619-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '', '')
620+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
621+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '', '')
622         self.assertEqual('files/test1.pdf', f.clean('', 'files/test1.pdf'))
623-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
624-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None, '')
625+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
626+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None, '')
627         self.assertEqual('files/test2.pdf', f.clean(None, 'files/test2.pdf'))
628-        self.assertRaisesErrorWithMessage(ValidationError, "[u'No file was submitted. Check the encoding type on the form.']", f.clean, SimpleUploadedFile('', ''))
629-        self.assertRaisesErrorWithMessage(ValidationError, "[u'No file was submitted. Check the encoding type on the form.']", f.clean, SimpleUploadedFile('', ''), '')
630+        self.assertRaisesMessage(ValidationError, "[u'No file was submitted. Check the encoding type on the form.']", f.clean, SimpleUploadedFile('', ''))
631+        self.assertRaisesMessage(ValidationError, "[u'No file was submitted. Check the encoding type on the form.']", f.clean, SimpleUploadedFile('', ''), '')
632         self.assertEqual('files/test3.pdf', f.clean(None, 'files/test3.pdf'))
633-        self.assertRaisesErrorWithMessage(ValidationError, "[u'No file was submitted. Check the encoding type on the form.']", f.clean, 'some content that is not a file')
634-        self.assertRaisesErrorWithMessage(ValidationError, "[u'The submitted file is empty.']", f.clean, SimpleUploadedFile('name', None))
635-        self.assertRaisesErrorWithMessage(ValidationError, "[u'The submitted file is empty.']", f.clean, SimpleUploadedFile('name', ''))
636+        self.assertRaisesMessage(ValidationError, "[u'No file was submitted. Check the encoding type on the form.']", f.clean, 'some content that is not a file')
637+        self.assertRaisesMessage(ValidationError, "[u'The submitted file is empty.']", f.clean, SimpleUploadedFile('name', None))
638+        self.assertRaisesMessage(ValidationError, "[u'The submitted file is empty.']", f.clean, SimpleUploadedFile('name', ''))
639         self.assertEqual(SimpleUploadedFile, type(f.clean(SimpleUploadedFile('name', 'Some File Content'))))
640         self.assertEqual(SimpleUploadedFile, type(f.clean(SimpleUploadedFile('我隻氣墊船裝滿晒鱔.txt', 'मेरी मँडराने वाली नाव सर्पमीनों से भरी ह'))))
641         self.assertEqual(SimpleUploadedFile, type(f.clean(SimpleUploadedFile('name', 'Some File Content'), 'files/test4.pdf')))
642 
643     def test_filefield_2(self):
644         f = FileField(max_length = 5)
645-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this filename has at most 5 characters (it has 18).']", f.clean, SimpleUploadedFile('test_maxlength.txt', 'hello world'))
646+        self.assertRaisesMessage(ValidationError, "[u'Ensure this filename has at most 5 characters (it has 18).']", f.clean, SimpleUploadedFile('test_maxlength.txt', 'hello world'))
647         self.assertEqual('files/test1.pdf', f.clean('', 'files/test1.pdf'))
648         self.assertEqual('files/test2.pdf', f.clean(None, 'files/test2.pdf'))
649         self.assertEqual(SimpleUploadedFile, type(f.clean(SimpleUploadedFile('name', 'Some File Content'))))
650@@ -569,8 +562,8 @@
651 
652     def test_urlfield_1(self):
653         f = URLField()
654-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
655-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
656+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
657+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
658         self.assertEqual(u'http://localhost/', f.clean('http://localhost'))
659         self.assertEqual(u'http://example.com/', f.clean('http://example.com'))
660         self.assertEqual(u'http://example.com./', f.clean('http://example.com.'))
661@@ -580,17 +573,17 @@
662         self.assertEqual(u'http://subdomain.domain.com/', f.clean('subdomain.domain.com'))
663         self.assertEqual(u'http://200.8.9.10/', f.clean('http://200.8.9.10'))
664         self.assertEqual(u'http://200.8.9.10:8000/test', f.clean('http://200.8.9.10:8000/test'))
665-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'foo')
666-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://')
667-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example')
668-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example.')
669-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'com.')
670-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, '.')
671-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://.com')
672-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://invalid-.com')
673-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://-invalid.com')
674-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://inv-.alid-.com')
675-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://inv-.-alid.com')
676+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'foo')
677+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://')
678+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example')
679+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example.')
680+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'com.')
681+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, '.')
682+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://.com')
683+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://invalid-.com')
684+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://-invalid.com')
685+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://inv-.alid-.com')
686+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://inv-.-alid.com')
687         self.assertEqual(u'http://valid-----hyphens.com/', f.clean('http://valid-----hyphens.com'))
688         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'))
689         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'))
690@@ -598,11 +591,11 @@
691     def test_url_regex_ticket11198(self):
692         f = URLField()
693         # hangs "forever" if catastrophic backtracking in ticket:#11198 not fixed
694-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://%s' % ("X"*200,))
695+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://%s' % ("X"*200,))
696 
697         # a second test, to make sure the problem is really addressed, even on
698         # domains that don't fail the domain label length check in the regex
699-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://%s' % ("X"*60,))
700+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://%s' % ("X"*60,))
701 
702     def test_urlfield_2(self):
703         f = URLField(required=False)
704@@ -610,17 +603,17 @@
705         self.assertEqual(u'', f.clean(None))
706         self.assertEqual(u'http://example.com/', f.clean('http://example.com'))
707         self.assertEqual(u'http://www.example.com/', f.clean('http://www.example.com'))
708-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'foo')
709-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://')
710-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example')
711-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example.')
712-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://.com')
713+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'foo')
714+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://')
715+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example')
716+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example.')
717+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://.com')
718 
719     @verify_exists_urls(('http://www.google.com/',))
720     def test_urlfield_3(self):
721         f = URLField(verify_exists=True)
722         self.assertEqual(u'http://www.google.com/', f.clean('http://www.google.com'))
723-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example')
724+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid URL.']", f.clean, 'http://example')
725         self.assertRaises(ValidationError, f.clean, 'http://www.broken.djangoproject.com') # bad domain
726         self.assertRaises(ValidationError, f.clean, 'http://qa-dev.w3.org/link-testsuite/http.php?code=405') # Method not allowed
727         try:
728@@ -641,9 +634,9 @@
729 
730     def test_urlfield_5(self):
731         f = URLField(min_length=15, max_length=20)
732-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at least 15 characters (it has 13).']", f.clean, 'http://f.com')
733+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at least 15 characters (it has 13).']", f.clean, 'http://f.com')
734         self.assertEqual(u'http://example.com/', f.clean('http://example.com'))
735-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at most 20 characters (it has 38).']", f.clean, 'http://abcdefghijklmnopqrstuvwxyz.com')
736+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at most 20 characters (it has 38).']", f.clean, 'http://abcdefghijklmnopqrstuvwxyz.com')
737 
738     def test_urlfield_6(self):
739         f = URLField(required=False)
740@@ -697,15 +690,15 @@
741 
742     def test_booleanfield_1(self):
743         f = BooleanField()
744-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
745-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
746+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
747+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
748         self.assertEqual(True, f.clean(True))
749-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, False)
750+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, False)
751         self.assertEqual(True, f.clean(1))
752-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, 0)
753+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, 0)
754         self.assertEqual(True, f.clean('Django rocks'))
755         self.assertEqual(True, f.clean('True'))
756-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, 'False')
757+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, 'False')
758 
759     def test_booleanfield_2(self):
760         f = BooleanField(required=False)
761@@ -726,11 +719,11 @@
762 
763     def test_choicefield_1(self):
764         f = ChoiceField(choices=[('1', 'One'), ('2', 'Two')])
765-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
766-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
767+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
768+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
769         self.assertEqual(u'1', f.clean(1))
770         self.assertEqual(u'1', f.clean('1'))
771-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, '3')
772+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, '3')
773 
774     def test_choicefield_2(self):
775         f = ChoiceField(choices=[('1', 'One'), ('2', 'Two')], required=False)
776@@ -738,12 +731,12 @@
777         self.assertEqual(u'', f.clean(None))
778         self.assertEqual(u'1', f.clean(1))
779         self.assertEqual(u'1', f.clean('1'))
780-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, '3')
781+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, '3')
782 
783     def test_choicefield_3(self):
784         f = ChoiceField(choices=[('J', 'John'), ('P', 'Paul')])
785         self.assertEqual(u'J', f.clean('J'))
786-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. John is not one of the available choices.']", f.clean, 'John')
787+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. John is not one of the available choices.']", f.clean, 'John')
788 
789     def test_choicefield_4(self):
790         f = ChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3','A'),('4','B'))), ('5','Other')])
791@@ -753,7 +746,7 @@
792         self.assertEqual(u'3', f.clean('3'))
793         self.assertEqual(u'5', f.clean(5))
794         self.assertEqual(u'5', f.clean('5'))
795-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 6 is not one of the available choices.']", f.clean, '6')
796+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 6 is not one of the available choices.']", f.clean, '6')
797 
798     # TypedChoiceField ############################################################
799     # TypedChoiceField is just like ChoiceField, except that coerced types will
800@@ -762,7 +755,7 @@
801     def test_typedchoicefield_1(self):
802         f = TypedChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int)
803         self.assertEqual(1, f.clean('1'))
804-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 2 is not one of the available choices.']", f.clean, '2')
805+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 2 is not one of the available choices.']", f.clean, '2')
806 
807     def test_typedchoicefield_2(self):
808         # Different coercion, same validation.
809@@ -778,9 +771,9 @@
810         # Even more weirdness: if you have a valid choice but your coercion function
811         # can't coerce, you'll still get a validation error. Don't do this!
812         f = TypedChoiceField(choices=[('A', 'A'), ('B', 'B')], coerce=int)
813-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. B is not one of the available choices.']", f.clean, 'B')
814+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. B is not one of the available choices.']", f.clean, 'B')
815         # Required fields require values
816-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
817+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
818 
819     def test_typedchoicefield_5(self):
820         # Non-required fields aren't required
821@@ -842,17 +835,17 @@
822 
823     def test_multiplechoicefield_1(self):
824         f = MultipleChoiceField(choices=[('1', 'One'), ('2', 'Two')])
825-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
826-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
827+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
828+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
829         self.assertEqual([u'1'], f.clean([1]))
830         self.assertEqual([u'1'], f.clean(['1']))
831         self.assertEqual([u'1', u'2'], f.clean(['1', '2']))
832         self.assertEqual([u'1', u'2'], f.clean([1, '2']))
833         self.assertEqual([u'1', u'2'], f.clean((1, '2')))
834-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a list of values.']", f.clean, 'hello')
835-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, [])
836-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, ())
837-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, ['3'])
838+        self.assertRaisesMessage(ValidationError, "[u'Enter a list of values.']", f.clean, 'hello')
839+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, [])
840+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, ())
841+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, ['3'])
842 
843     def test_multiplechoicefield_2(self):
844         f = MultipleChoiceField(choices=[('1', 'One'), ('2', 'Two')], required=False)
845@@ -863,10 +856,10 @@
846         self.assertEqual([u'1', u'2'], f.clean(['1', '2']))
847         self.assertEqual([u'1', u'2'], f.clean([1, '2']))
848         self.assertEqual([u'1', u'2'], f.clean((1, '2')))
849-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a list of values.']", f.clean, 'hello')
850+        self.assertRaisesMessage(ValidationError, "[u'Enter a list of values.']", f.clean, 'hello')
851         self.assertEqual([], f.clean([]))
852         self.assertEqual([], f.clean(()))
853-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, ['3'])
854+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 3 is not one of the available choices.']", f.clean, ['3'])
855 
856     def test_multiplechoicefield_3(self):
857         f = MultipleChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3','A'),('4','B'))), ('5','Other')])
858@@ -876,8 +869,8 @@
859         self.assertEqual([u'1', u'5'], f.clean([1, '5']))
860         self.assertEqual([u'1', u'5'], f.clean(['1', 5]))
861         self.assertEqual([u'1', u'5'], f.clean(['1', '5']))
862-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 6 is not one of the available choices.']", f.clean, ['6'])
863-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 6 is not one of the available choices.']", f.clean, ['1','6'])
864+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 6 is not one of the available choices.']", f.clean, ['6'])
865+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 6 is not one of the available choices.']", f.clean, ['1','6'])
866 
867     # TypedMultipleChoiceField ############################################################
868     # TypedMultipleChoiceField is just like MultipleChoiceField, except that coerced types
869@@ -886,7 +879,7 @@
870     def test_typedmultiplechoicefield_1(self):
871         f = TypedMultipleChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int)
872         self.assertEqual([1], f.clean(['1']))
873-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 2 is not one of the available choices.']", f.clean, ['2'])
874+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 2 is not one of the available choices.']", f.clean, ['2'])
875 
876     def test_typedmultiplechoicefield_2(self):
877         # Different coercion, same validation.
878@@ -901,15 +894,15 @@
879     def test_typedmultiplechoicefield_4(self):
880         f = TypedMultipleChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int)
881         self.assertEqual([1, -1], f.clean(['1','-1']))
882-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. 2 is not one of the available choices.']", f.clean, ['1','2'])
883+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. 2 is not one of the available choices.']", f.clean, ['1','2'])
884 
885     def test_typedmultiplechoicefield_5(self):
886         # Even more weirdness: if you have a valid choice but your coercion function
887         # can't coerce, you'll still get a validation error. Don't do this!
888         f = TypedMultipleChoiceField(choices=[('A', 'A'), ('B', 'B')], coerce=int)
889-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. B is not one of the available choices.']", f.clean, ['B'])
890+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. B is not one of the available choices.']", f.clean, ['B'])
891         # Required fields require values
892-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, [])
893+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, [])
894 
895     def test_typedmultiplechoicefield_6(self):
896         # Non-required fields aren't required
897@@ -926,16 +919,16 @@
898     def test_combofield_1(self):
899         f = ComboField(fields=[CharField(max_length=20), EmailField()])
900         self.assertEqual(u'test@example.com', f.clean('test@example.com'))
901-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at most 20 characters (it has 28).']", f.clean, 'longemailaddress@example.com')
902-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'not an e-mail')
903-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
904-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
905+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at most 20 characters (it has 28).']", f.clean, 'longemailaddress@example.com')
906+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'not an e-mail')
907+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
908+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
909 
910     def test_combofield_2(self):
911         f = ComboField(fields=[CharField(max_length=20), EmailField()], required=False)
912         self.assertEqual(u'test@example.com', f.clean('test@example.com'))
913-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Ensure this value has at most 20 characters (it has 28).']", f.clean, 'longemailaddress@example.com')
914-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'not an e-mail')
915+        self.assertRaisesMessage(ValidationError, "[u'Ensure this value has at most 20 characters (it has 28).']", f.clean, 'longemailaddress@example.com')
916+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'not an e-mail')
917         self.assertEqual(u'', f.clean(''))
918         self.assertEqual(u'', f.clean(None))
919 
920@@ -964,7 +957,7 @@
921         for exp, got in zip(expected, fix_os_paths(f.choices)):
922             self.assertEqual(exp[1], got[1])
923             self.assertTrue(got[0].endswith(exp[0]))
924-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Select a valid choice. fields.py is not one of the available choices.']", f.clean, 'fields.py')
925+        self.assertRaisesMessage(ValidationError, "[u'Select a valid choice. fields.py is not one of the available choices.']", f.clean, 'fields.py')
926         assert fix_os_paths(f.clean(path + 'fields.py')).endswith('/django/forms/fields.py')
927 
928     def test_filepathfield_3(self):
929@@ -1012,12 +1005,12 @@
930         f = SplitDateTimeField()
931         assert isinstance(f.widget, SplitDateTimeWidget)
932         self.assertEqual(datetime.datetime(2006, 1, 10, 7, 30), f.clean([datetime.date(2006, 1, 10), datetime.time(7, 30)]))
933-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, None)
934-        self.assertRaisesErrorWithMessage(ValidationError, "[u'This field is required.']", f.clean, '')
935-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a list of values.']", f.clean, 'hello')
936-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.', u'Enter a valid time.']", f.clean, ['hello', 'there'])
937-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid time.']", f.clean, ['2006-01-10', 'there'])
938-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, ['hello', '07:30'])
939+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, None)
940+        self.assertRaisesMessage(ValidationError, "[u'This field is required.']", f.clean, '')
941+        self.assertRaisesMessage(ValidationError, "[u'Enter a list of values.']", f.clean, 'hello')
942+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.', u'Enter a valid time.']", f.clean, ['hello', 'there'])
943+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid time.']", f.clean, ['2006-01-10', 'there'])
944+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, ['hello', '07:30'])
945 
946     def test_splitdatetimefield_2(self):
947         f = SplitDateTimeField(required=False)
948@@ -1027,10 +1020,10 @@
949         self.assertEqual(None, f.clean(''))
950         self.assertEqual(None, f.clean(['']))
951         self.assertEqual(None, f.clean(['', '']))
952-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a list of values.']", f.clean, 'hello')
953-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.', u'Enter a valid time.']", f.clean, ['hello', 'there'])
954-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid time.']", f.clean, ['2006-01-10', 'there'])
955-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, ['hello', '07:30'])
956-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid time.']", f.clean, ['2006-01-10', ''])
957-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid time.']", f.clean, ['2006-01-10'])
958-        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid date.']", f.clean, ['', '07:30'])
959+        self.assertRaisesMessage(ValidationError, "[u'Enter a list of values.']", f.clean, 'hello')
960+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.', u'Enter a valid time.']", f.clean, ['hello', 'there'])
961+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid time.']", f.clean, ['2006-01-10', 'there'])
962+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, ['hello', '07:30'])
963+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid time.']", f.clean, ['2006-01-10', ''])
964+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid time.']", f.clean, ['2006-01-10'])
965+        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date.']", f.clean, ['', '07:30'])
966diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py
967--- a/tests/regressiontests/queries/tests.py
968+++ b/tests/regressiontests/queries/tests.py
969@@ -22,19 +22,6 @@
970     def assertValueQuerysetEqual(self, qs, values):
971         return self.assertQuerysetEqual(qs, values, transform=lambda x: x)
972 
973-    def assertRaisesMessage(self, exc, msg, func, *args, **kwargs):
974-        try:
975-            func(*args, **kwargs)
976-        except Exception, e:
977-            self.assertEqual(msg, str(e))
978-            self.assertTrue(isinstance(e, exc), "Expected %s, got %s" % (exc, type(e)))
979-        else:
980-            if hasattr(exc, '__name__'):
981-                excName = exc.__name__
982-            else:
983-                excName = str(exc)
984-            raise AssertionError("%s not raised" % excName)
985-
986 
987 class Queries1Tests(BaseQuerysetTest):
988     def setUp(self):
989diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py
990--- a/tests/regressiontests/urlpatterns_reverse/tests.py
991+++ b/tests/regressiontests/urlpatterns_reverse/tests.py
992@@ -138,21 +138,13 @@
993 class NoURLPatternsTests(TestCase):
994     urls = 'regressiontests.urlpatterns_reverse.no_urls'
995 
996-    def assertRaisesErrorWithMessage(self, error, message, callable,
997-        *args, **kwargs):
998-        self.assertRaises(error, callable, *args, **kwargs)
999-        try:
1000-            callable(*args, **kwargs)
1001-        except error, e:
1002-            self.assertEqual(message, str(e))
1003-
1004     def test_no_urls_exception(self):
1005         """
1006         RegexURLResolver should raise an exception when no urlpatterns exist.
1007         """
1008         resolver = RegexURLResolver(r'^$', self.urls)
1009 
1010-        self.assertRaisesErrorWithMessage(ImproperlyConfigured,
1011+        self.assertRaisesMessage(ImproperlyConfigured,
1012             "The included urlconf regressiontests.urlpatterns_reverse.no_urls "\
1013             "doesn't have any patterns in it", getattr, resolver, 'url_patterns')
1014 
1015diff --git a/tests/regressiontests/utils/datastructures.py b/tests/regressiontests/utils/datastructures.py
1016--- a/tests/regressiontests/utils/datastructures.py
1017+++ b/tests/regressiontests/utils/datastructures.py
1018@@ -4,19 +4,13 @@
1019 
1020 import copy
1021 import pickle
1022-import unittest
1023 
1024+from django.test import SimpleTestCase
1025 from django.utils.datastructures import *
1026 
1027 
1028-class DatastructuresTestCase(unittest.TestCase):
1029-    def assertRaisesErrorWithMessage(self, error, message, callable,
1030-        *args, **kwargs):
1031-        self.assertRaises(error, callable, *args, **kwargs)
1032-        try:
1033-            callable(*args, **kwargs)
1034-        except error, e:
1035-            self.assertEqual(message, str(e))
1036+class DatastructuresTestCase(SimpleTestCase):
1037+    pass
1038 
1039 
1040 class SortedDictTests(DatastructuresTestCase):
1041@@ -198,7 +192,7 @@
1042         # MultiValueDictKeyError: "Key 'lastname' not found in
1043         # <MultiValueDict: {'position': ['Developer'],
1044         #                   'name': ['Adrian', 'Simon']}>"
1045-        self.assertRaisesErrorWithMessage(MultiValueDictKeyError,
1046+        self.assertRaisesMessage(MultiValueDictKeyError,
1047             '"Key \'lastname\' not found in <MultiValueDict: {\'position\':'\
1048             ' [\'Developer\'], \'name\': [\'Adrian\', \'Simon\']}>"',
1049             d.__getitem__, 'lastname')
1050@@ -268,7 +262,7 @@
1051         d = ImmutableList(range(10))
1052 
1053         # AttributeError: ImmutableList object is immutable.
1054-        self.assertRaisesErrorWithMessage(AttributeError,
1055+        self.assertRaisesMessage(AttributeError,
1056             'ImmutableList object is immutable.', d.sort)
1057 
1058         self.assertEqual(repr(d), '(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)')
1059@@ -279,7 +273,7 @@
1060         self.assertEqual(d[1], 1)
1061 
1062         # AttributeError: Object is immutable!
1063-        self.assertRaisesErrorWithMessage(AttributeError,
1064+        self.assertRaisesMessage(AttributeError,
1065             'Object is immutable!', d.__setitem__, 1, 'test')
1066 
1067