From 40260bc30b11bfe0134107bf9dc82a0cd1dcd800 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Mon, 4 Feb 2013 18:00:19 +0100 Subject: [PATCH] Fixed error message test assertions under Python 3.3 Thanks Florian Apolloner for testing. --- tests/regressiontests/file_storage/tests.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py index 6ab7f90ee7..8555a72e5e 100644 --- a/tests/regressiontests/file_storage/tests.py +++ b/tests/regressiontests/file_storage/tests.py @@ -55,11 +55,9 @@ class GetStorageClassTests(SimpleTestCase): """ get_storage_class raises an error if the requested import don't exist. """ - self.assertRaisesMessage( - ImproperlyConfigured, - "Error importing module storage: \"No module named storage\"", - get_storage_class, - 'storage.NonExistingStorage') + with six.assertRaisesRegex(self, ImproperlyConfigured, + "Error importing module storage: \"No module named '?storage'?\""): + get_storage_class('storage.NonExistingStorage') def test_get_nonexisting_storage_class(self): """ @@ -77,13 +75,11 @@ class GetStorageClassTests(SimpleTestCase): get_storage_class raises an error if the requested module don't exist. """ # Error message may or may not be the fully qualified path. - six.assertRaisesRegex(self, - ImproperlyConfigured, - 'Error importing module django.core.files.non_existing_storage: ' - '"No module named non_existing_storage"', - get_storage_class, - 'django.core.files.non_existing_storage.NonExistingStorage' - ) + with six.assertRaisesRegex(self, ImproperlyConfigured, + "Error importing module django.core.files.non_existing_storage: " + "\"No module named '?(django.core.files.)?non_existing_storage'?\""): + get_storage_class( + 'django.core.files.non_existing_storage.NonExistingStorage') class FileStorageTests(unittest.TestCase): storage_class = FileSystemStorage