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)"]) "datetime.datetime(2005, 7, 28, 0, 0)"])
# dates() requires valid arguments. # dates() requires valid arguments.
six.assertRaisesRegex(self, self.assertRaises(
TypeError, TypeError,
"dates\(\) takes at least 3 arguments \(1 given\)",
Article.objects.dates, Article.objects.dates,
) )

View File

@ -1010,7 +1010,8 @@ class ManageSettingsWithImportError(AdminScriptTestCase):
args = ['sqlall', 'admin_scripts'] args = ['sqlall', 'admin_scripts']
out, err = self.run_manage(args) out, err = self.run_manage(args)
self.assertNoOutput(out) 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): def test_builtin_command_with_attribute_error(self):
""" """
@ -1033,7 +1034,8 @@ class ManageValidate(AdminScriptTestCase):
args = ['validate'] args = ['validate']
out, err = self.run_manage(args) out, err = self.run_manage(args)
self.assertNoOutput(out) 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): def test_broken_app(self):
"manage.py validate reports an ImportError if an app's models.py raises one on import" "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, six.assertRaisesRegex(self,
ImproperlyConfigured, ImproperlyConfigured,
('Error importing storage module django.core.files.non_existing_' ('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, get_storage_class,
'django.core.files.non_existing_storage.NonExistingStorage' '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 Test that failing serializer import raises the proper error
""" """
with six.assertRaisesRegex(self, ImportError, with six.assertRaisesRegex(self, ImportError,
"No module named unexistent.path"): r"No module named.*unexistent"):
management.call_command( management.call_command(
'loaddata', 'loaddata',
'bad_fixture1.unkn', 'bad_fixture1.unkn',