Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed a few other backporting-related bugs introduced in r14213.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14247 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 55d8c47d29ce24428fbfd425a5ae6030bbeaf09f 1 parent 630b1fc
Jannis Leidel authored
13  tests/regressiontests/inline_formsets/tests.py
@@ -107,6 +107,13 @@ def test_save_new(self):
107 107
 
108 108
 
109 109
 class InlineFormsetFactoryTest(TestCase):
  110
+    def assertRaisesErrorWithMessage(self, error, message, callable, *args, **kwargs):
  111
+        self.assertRaises(error, callable, *args, **kwargs)
  112
+        try:
  113
+            callable(*args, **kwargs)
  114
+        except error, e:
  115
+            self.assertEqual(message, str(e))
  116
+
110 117
     def test_inline_formset_factory(self):
111 118
         """
112 119
         These should both work without a problem.
@@ -119,7 +126,7 @@ def test_exception_on_unspecified_foreign_key(self):
119 126
         Child has two ForeignKeys to Parent, so if we don't specify which one
120 127
         to use for the inline formset, we should get an exception.
121 128
         """
122  
-        self.assertRaisesRegexp(Exception,
  129
+        self.assertRaisesErrorWithMessage(Exception,
123 130
             "<class 'regressiontests.inline_formsets.models.Child'> has more than 1 ForeignKey to <class 'regressiontests.inline_formsets.models.Parent'>",
124 131
             inlineformset_factory, Parent, Child
125 132
         )
@@ -129,7 +136,7 @@ def test_fk_name_not_foreign_key_field_from_child(self):
129 136
         If we specify fk_name, but it isn't a ForeignKey from the child model
130 137
         to the parent model, we should get an exception.
131 138
         """
132  
-        self.assertRaises(Exception,
  139
+        self.assertRaisesErrorWithMessage(Exception,
133 140
             "fk_name 'school' is not a ForeignKey to <class 'regressiontests.inline_formsets.models.Parent'>",
134 141
             inlineformset_factory, Parent, Child, fk_name='school'
135 142
         )
@@ -139,7 +146,7 @@ def test_non_foreign_key_field(self):
139 146
         If the field specified in fk_name is not a ForeignKey, we should get an
140 147
         exception.
141 148
         """
142  
-        self.assertRaisesRegexp(Exception,
  149
+        self.assertRaisesErrorWithMessage(Exception,
143 150
             "<class 'regressiontests.inline_formsets.models.Child'> has no field named 'test'",
144 151
             inlineformset_factory, Parent, Child, fk_name='test'
145 152
         )
11  tests/regressiontests/m2m_regress/tests.py
@@ -6,6 +6,13 @@
6 6
 
7 7
 
8 8
 class M2MRegressionTests(TestCase):
  9
+    def assertRaisesErrorWithMessage(self, error, message, callable, *args, **kwargs):
  10
+        self.assertRaises(error, callable, *args, **kwargs)
  11
+        try:
  12
+            callable(*args, **kwargs)
  13
+        except error, e:
  14
+            self.assertEqual(message, str(e))
  15
+
9 16
     def test_multiple_m2m(self):
10 17
         # Multiple m2m references to model must be distinguished when
11 18
         # accessing the relations through an instance attribute.
@@ -33,8 +40,8 @@ def test_internal_related_name_not_in_error_msg(self):
33 40
         # The secret internal related names for self-referential many-to-many
34 41
         # fields shouldn't appear in the list when an error is made.
35 42
 
36  
-        self.assertRaisesRegexp(FieldError,
37  
-            "Choices are: id, name, references, related, selfreferchild, selfreferchildsibling$",
  43
+        self.assertRaisesErrorWithMessage(FieldError,
  44
+            "Cannot resolve keyword 'porcupine' into field. Choices are: id, name, references, related, selfreferchild, selfreferchildsibling",
38 45
             lambda: SelfRefer.objects.filter(porcupine='fred')
39 46
         )
40 47
 

0 notes on commit 55d8c47

Please sign in to comment.
Something went wrong with that request. Please try again.