mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #14503 -- Unified multiple implementations of test cases assert* methods that verify a given exception is raised by a callable throughout the Django test suite.
Replaced them with a new assertRaisesMessage method of a new SimpleTestCase, a lightweight subclass of unittest.TestCase. Both are also available for usage in user tests. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16610 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -22,19 +22,6 @@ class BaseQuerysetTest(TestCase):
|
||||
def assertValueQuerysetEqual(self, qs, values):
|
||||
return self.assertQuerysetEqual(qs, values, transform=lambda x: x)
|
||||
|
||||
def assertRaisesMessage(self, exc, msg, func, *args, **kwargs):
|
||||
try:
|
||||
func(*args, **kwargs)
|
||||
except Exception, e:
|
||||
self.assertEqual(msg, str(e))
|
||||
self.assertTrue(isinstance(e, exc), "Expected %s, got %s" % (exc, type(e)))
|
||||
else:
|
||||
if hasattr(exc, '__name__'):
|
||||
excName = exc.__name__
|
||||
else:
|
||||
excName = str(exc)
|
||||
raise AssertionError("%s not raised" % excName)
|
||||
|
||||
|
||||
class Queries1Tests(BaseQuerysetTest):
|
||||
def setUp(self):
|
||||
|
||||
Reference in New Issue
Block a user