Avoid dependence on exact Python exception messages

This commit is contained in:
Ian Clelland 2012-09-28 10:17:40 -07:00 committed by Luke Plant
parent 02dda22832
commit bdcd2f6b10
4 changed files with 7 additions and 6 deletions

View File

@ -259,9 +259,8 @@ class ModelTest(TestCase):
"datetime.datetime(2005, 7, 28, 0, 0)"])
# dates() requires valid arguments.
six.assertRaisesRegex(self,
self.assertRaises(
TypeError,
"dates\(\) takes at least 3 arguments \(1 given\)",
Article.objects.dates,
)

View File

@ -1010,7 +1010,8 @@ class ManageSettingsWithImportError(AdminScriptTestCase):
args = ['sqlall', 'admin_scripts']
out, err = self.run_manage(args)
self.assertNoOutput(out)
self.assertOutput(err, "No module named foo42bar")
self.assertOutput(err, "No module named")
self.assertOutput(err, "foo42bar")
def test_builtin_command_with_attribute_error(self):
"""
@ -1033,7 +1034,8 @@ class ManageValidate(AdminScriptTestCase):
args = ['validate']
out, err = self.run_manage(args)
self.assertNoOutput(out)
self.assertOutput(err, 'No module named admin_scriptz')
self.assertOutput(err, 'No module named')
self.assertOutput(err, 'admin_scriptz')
def test_broken_app(self):
"manage.py validate reports an ImportError if an app's models.py raises one on import"

View File

@ -78,7 +78,7 @@ class GetStorageClassTests(SimpleTestCase):
six.assertRaisesRegex(self,
ImproperlyConfigured,
('Error importing storage module django.core.files.non_existing_'
'storage: "No module named .*non_existing_storage"'),
'storage: "No module named .*non_existing_storage'),
get_storage_class,
'django.core.files.non_existing_storage.NonExistingStorage'
)

View File

@ -159,7 +159,7 @@ class TestFixtures(TestCase):
Test that failing serializer import raises the proper error
"""
with six.assertRaisesRegex(self, ImportError,
"No module named unexistent.path"):
r"No module named.*unexistent"):
management.call_command(
'loaddata',
'bad_fixture1.unkn',