mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Refs #26022 -- Replaced six.assertRaisesRegex with assertRaisesMessage as appropriate.
This commit is contained in:
parent
253adc2b8a
commit
26ad01719d
23 changed files with 124 additions and 221 deletions
|
@ -49,8 +49,8 @@ class MultiValueDictTests(SimpleTestCase):
|
|||
[('name', ['Adrian', 'Simon']), ('position', ['Developer'])]
|
||||
)
|
||||
|
||||
six.assertRaisesRegex(self, MultiValueDictKeyError, 'lastname',
|
||||
d.__getitem__, 'lastname')
|
||||
with self.assertRaisesMessage(MultiValueDictKeyError, 'lastname'):
|
||||
d.__getitem__('lastname')
|
||||
|
||||
self.assertEqual(d.get('lastname'), None)
|
||||
self.assertEqual(d.get('lastname', 'nonexistent'), 'nonexistent')
|
||||
|
|
|
@ -5,7 +5,7 @@ import unittest
|
|||
from importlib import import_module
|
||||
from zipimport import zipimporter
|
||||
|
||||
from django.test import SimpleTestCase, modify_settings
|
||||
from django.test import SimpleTestCase, TestCase, modify_settings
|
||||
from django.test.utils import extend_sys_path
|
||||
from django.utils import six
|
||||
from django.utils._os import upath
|
||||
|
@ -115,7 +115,7 @@ class EggLoader(unittest.TestCase):
|
|||
import_module('egg_module.sub1.sub2.no_such_module')
|
||||
|
||||
|
||||
class ModuleImportTestCase(unittest.TestCase):
|
||||
class ModuleImportTestCase(TestCase):
|
||||
def test_import_string(self):
|
||||
cls = import_string('django.utils.module_loading.import_string')
|
||||
self.assertEqual(cls, import_string)
|
||||
|
@ -124,7 +124,7 @@ class ModuleImportTestCase(unittest.TestCase):
|
|||
with self.assertRaises(ImportError):
|
||||
import_string('no_dots_in_path')
|
||||
msg = 'Module "utils_tests" does not define a "unexistent" attribute'
|
||||
with six.assertRaisesRegex(self, ImportError, msg):
|
||||
with self.assertRaisesMessage(ImportError, msg):
|
||||
import_string('utils_tests.unexistent')
|
||||
|
||||
|
||||
|
@ -164,13 +164,13 @@ class AutodiscoverModulesTestCase(SimpleTestCase):
|
|||
|
||||
def test_validate_registry_keeps_intact(self):
|
||||
from .test_module import site
|
||||
with six.assertRaisesRegex(self, Exception, "Some random exception."):
|
||||
with self.assertRaisesMessage(Exception, "Some random exception."):
|
||||
autodiscover_modules('another_bad_module', register_to=site)
|
||||
self.assertEqual(site._registry, {})
|
||||
|
||||
def test_validate_registry_resets_after_erroneous_module(self):
|
||||
from .test_module import site
|
||||
with six.assertRaisesRegex(self, Exception, "Some random exception."):
|
||||
with self.assertRaisesMessage(Exception, "Some random exception."):
|
||||
autodiscover_modules('another_good_module', 'another_bad_module', register_to=site)
|
||||
self.assertEqual(site._registry, {'lorem': 'ipsum'})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue