Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[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
@jezdez jezdez authored
View
13 tests/regressiontests/inline_formsets/tests.py
@@ -107,6 +107,13 @@ def test_save_new(self):
class InlineFormsetFactoryTest(TestCase):
+ def assertRaisesErrorWithMessage(self, error, message, callable, *args, **kwargs):
+ self.assertRaises(error, callable, *args, **kwargs)
+ try:
+ callable(*args, **kwargs)
+ except error, e:
+ self.assertEqual(message, str(e))
+
def test_inline_formset_factory(self):
"""
These should both work without a problem.
@@ -119,7 +126,7 @@ def test_exception_on_unspecified_foreign_key(self):
Child has two ForeignKeys to Parent, so if we don't specify which one
to use for the inline formset, we should get an exception.
"""
- self.assertRaisesRegexp(Exception,
+ self.assertRaisesErrorWithMessage(Exception,
"<class 'regressiontests.inline_formsets.models.Child'> has more than 1 ForeignKey to <class 'regressiontests.inline_formsets.models.Parent'>",
inlineformset_factory, Parent, Child
)
@@ -129,7 +136,7 @@ def test_fk_name_not_foreign_key_field_from_child(self):
If we specify fk_name, but it isn't a ForeignKey from the child model
to the parent model, we should get an exception.
"""
- self.assertRaises(Exception,
+ self.assertRaisesErrorWithMessage(Exception,
"fk_name 'school' is not a ForeignKey to <class 'regressiontests.inline_formsets.models.Parent'>",
inlineformset_factory, Parent, Child, fk_name='school'
)
@@ -139,7 +146,7 @@ def test_non_foreign_key_field(self):
If the field specified in fk_name is not a ForeignKey, we should get an
exception.
"""
- self.assertRaisesRegexp(Exception,
+ self.assertRaisesErrorWithMessage(Exception,
"<class 'regressiontests.inline_formsets.models.Child'> has no field named 'test'",
inlineformset_factory, Parent, Child, fk_name='test'
)
View
11 tests/regressiontests/m2m_regress/tests.py
@@ -6,6 +6,13 @@
class M2MRegressionTests(TestCase):
+ def assertRaisesErrorWithMessage(self, error, message, callable, *args, **kwargs):
+ self.assertRaises(error, callable, *args, **kwargs)
+ try:
+ callable(*args, **kwargs)
+ except error, e:
+ self.assertEqual(message, str(e))
+
def test_multiple_m2m(self):
# Multiple m2m references to model must be distinguished when
# accessing the relations through an instance attribute.
@@ -33,8 +40,8 @@ def test_internal_related_name_not_in_error_msg(self):
# The secret internal related names for self-referential many-to-many
# fields shouldn't appear in the list when an error is made.
- self.assertRaisesRegexp(FieldError,
- "Choices are: id, name, references, related, selfreferchild, selfreferchildsibling$",
+ self.assertRaisesErrorWithMessage(FieldError,
+ "Cannot resolve keyword 'porcupine' into field. Choices are: id, name, references, related, selfreferchild, selfreferchildsibling",
lambda: SelfRefer.objects.filter(porcupine='fred')
)
Please sign in to comment.
Something went wrong with that request. Please try again.