From fc4f45ebdccd87f140f39bebed897053c7f345c5 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Tue, 4 Feb 2020 21:58:07 +0100 Subject: Used assertRaisesMessage() in various tests. --- tests/admin_autodiscover/tests.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'tests/admin_autodiscover') diff --git a/tests/admin_autodiscover/tests.py b/tests/admin_autodiscover/tests.py index af5aebcd7f..b15060ade8 100644 --- a/tests/admin_autodiscover/tests.py +++ b/tests/admin_autodiscover/tests.py @@ -1,21 +1,17 @@ -from unittest import TestCase - from django.contrib import admin +from django.test import SimpleTestCase -class AdminAutoDiscoverTests(TestCase): +class AdminAutoDiscoverTests(SimpleTestCase): """ Test for bug #8245 - don't raise an AlreadyRegistered exception when using autodiscover() and an admin.py module contains an error. """ def test_double_call_autodiscover(self): # The first time autodiscover is called, we should get our real error. - with self.assertRaises(Exception) as cm: + with self.assertRaisesMessage(Exception, 'Bad admin module'): admin.autodiscover() - self.assertEqual(str(cm.exception), "Bad admin module") - # Calling autodiscover again should raise the very same error it did # the first time, not an AlreadyRegistered error. - with self.assertRaises(Exception) as cm: + with self.assertRaisesMessage(Exception, 'Bad admin module'): admin.autodiscover() - self.assertEqual(str(cm.exception), "Bad admin module") -- cgit v1.3