1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +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:
Ramiro Morales
2011-08-13 00:42:08 +00:00
parent a539d434d9
commit 326949e444
13 changed files with 299 additions and 292 deletions

View File

@@ -1,6 +1,6 @@
from __future__ import with_statement
from django.test import TestCase, skipUnlessDBFeature
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
from django.utils.unittest import skip
from models import Person
@@ -48,6 +48,7 @@ class AssertNumQueriesTests(TestCase):
self.client.get("/test_utils/get_person/%s/" % person.pk)
self.assertNumQueries(2, test_func)
class AssertNumQueriesContextManagerTests(TestCase):
urls = 'regressiontests.test_utils.urls'
@@ -129,6 +130,15 @@ class SkippingExtraTests(TestCase):
pass
class AssertRaisesMsgTest(SimpleTestCase):
def test_special_re_chars(self):
"""assertRaisesMessage shouldn't interpret RE special chars."""
def func1():
raise ValueError("[.*x+]y?")
self.assertRaisesMessage(ValueError, "[.*x+]y?", func1)
__test__ = {"API_TEST": r"""
# Some checks of the doctest output normalizer.
# Standard doctests do fairly