Refs #23919 -- Simplified assertRaisesRegex()'s that accounted for Python 2.

This commit is contained in:
Tim Graham 2017-01-19 21:10:33 -05:00 committed by Aymeric Augustin
parent dc8834cad4
commit 109b33f64c
12 changed files with 43 additions and 42 deletions

View file

@ -45,7 +45,7 @@ class GetStorageClassTests(SimpleTestCase):
"""
get_storage_class raises an error if the requested import don't exist.
"""
with self.assertRaisesRegex(ImportError, "No module named '?storage'?"):
with self.assertRaisesMessage(ImportError, "No module named 'storage'"):
get_storage_class('storage.NonExistingStorage')
def test_get_nonexisting_storage_class(self):
@ -59,8 +59,7 @@ 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.
with self.assertRaisesRegex(ImportError, "No module named '?(django.core.files.)?non_existing_storage'?"):
with self.assertRaisesMessage(ImportError, "No module named 'django.core.files.non_existing_storage'"):
get_storage_class('django.core.files.non_existing_storage.NonExistingStorage')