From 3d0dcd7f5af378d3ab6adb303b913e6c7b2e0ee5 Mon Sep 17 00:00:00 2001 From: Hasan Date: Sun, 17 Jan 2016 14:56:39 +0330 Subject: Refs #26022 -- Used context manager version of assertRaises in tests. --- tests/inline_formsets/tests.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tests/inline_formsets') diff --git a/tests/inline_formsets/tests.py b/tests/inline_formsets/tests.py index 167d2a68e1..3bb7586575 100644 --- a/tests/inline_formsets/tests.py +++ b/tests/inline_formsets/tests.py @@ -135,11 +135,9 @@ class InlineFormsetFactoryTest(TestCase): 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, - "fk_name 'school' is not a ForeignKey to ", - inlineformset_factory, Parent, Child, fk_name='school' - ) + msg = "fk_name 'school' is not a ForeignKey to 'inline_formsets.Parent'." + with self.assertRaisesMessage(ValueError, msg): + inlineformset_factory(Parent, Child, fk_name='school') def test_non_foreign_key_field(self): """ -- cgit v1.3