From bdcd2f6b105fffea0b8438625a29a1ccb2962680 Mon Sep 17 00:00:00 2001 From: Ian Clelland Date: Fri, 28 Sep 2012 10:17:40 -0700 Subject: [PATCH] Avoid dependence on exact Python exception messages --- tests/modeltests/basic/tests.py | 3 +-- tests/regressiontests/admin_scripts/tests.py | 6 ++++-- tests/regressiontests/file_storage/tests.py | 2 +- tests/regressiontests/fixtures_regress/tests.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/modeltests/basic/tests.py b/tests/modeltests/basic/tests.py index 6ec9ca03afd..ebd70d14d9a 100644 --- a/tests/modeltests/basic/tests.py +++ b/tests/modeltests/basic/tests.py @@ -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, ) diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py index a5deba7fe16..3bb8bb0b50d 100644 --- a/tests/regressiontests/admin_scripts/tests.py +++ b/tests/regressiontests/admin_scripts/tests.py @@ -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" diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py index 6b57ad6160e..595b65d9f1d 100644 --- a/tests/regressiontests/file_storage/tests.py +++ b/tests/regressiontests/file_storage/tests.py @@ -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' ) diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py index 678db4a9cc2..55363bc5b76 100644 --- a/tests/regressiontests/fixtures_regress/tests.py +++ b/tests/regressiontests/fixtures_regress/tests.py @@ -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',