mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #27579 -- Added aliases for Python 3's assertion names in SimpleTestCase.
This commit is contained in:
parent
f909fa84be
commit
b5f0b3478d
27 changed files with 84 additions and 104 deletions
|
@ -49,7 +49,7 @@ class GetStorageClassTests(SimpleTestCase):
|
|||
"""
|
||||
get_storage_class raises an error if the requested import don't exist.
|
||||
"""
|
||||
with six.assertRaisesRegex(self, ImportError, "No module named '?storage'?"):
|
||||
with self.assertRaisesRegex(ImportError, "No module named '?storage'?"):
|
||||
get_storage_class('storage.NonExistingStorage')
|
||||
|
||||
def test_get_nonexisting_storage_class(self):
|
||||
|
@ -64,7 +64,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 six.assertRaisesRegex(self, ImportError, "No module named '?(django.core.files.)?non_existing_storage'?"):
|
||||
with self.assertRaisesRegex(ImportError, "No module named '?(django.core.files.)?non_existing_storage'?"):
|
||||
get_storage_class('django.core.files.non_existing_storage.NonExistingStorage')
|
||||
|
||||
|
||||
|
@ -703,7 +703,7 @@ class FileFieldStorageTests(TestCase):
|
|||
obj2 = Storage()
|
||||
obj2.normal.save("django_test.txt", ContentFile("more content"))
|
||||
obj2_name = obj2.normal.name
|
||||
six.assertRegex(self, obj2_name, "tests/django_test_%s.txt" % FILE_SUFFIX_REGEX)
|
||||
self.assertRegex(obj2_name, "tests/django_test_%s.txt" % FILE_SUFFIX_REGEX)
|
||||
self.assertEqual(obj2.normal.size, 12)
|
||||
obj2.normal.close()
|
||||
|
||||
|
@ -711,7 +711,7 @@ class FileFieldStorageTests(TestCase):
|
|||
obj2.delete()
|
||||
obj2.normal.save("django_test.txt", ContentFile("more content"))
|
||||
self.assertNotEqual(obj2_name, obj2.normal.name)
|
||||
six.assertRegex(self, obj2.normal.name, "tests/django_test_%s.txt" % FILE_SUFFIX_REGEX)
|
||||
self.assertRegex(obj2.normal.name, "tests/django_test_%s.txt" % FILE_SUFFIX_REGEX)
|
||||
obj2.normal.close()
|
||||
|
||||
def test_filefield_read(self):
|
||||
|
@ -750,7 +750,7 @@ class FileFieldStorageTests(TestCase):
|
|||
try:
|
||||
names = [o.normal.name for o in objs]
|
||||
self.assertEqual(names[0], "tests/multiple_files.txt")
|
||||
six.assertRegex(self, names[1], "tests/multiple_files_%s.txt" % FILE_SUFFIX_REGEX)
|
||||
self.assertRegex(names[1], "tests/multiple_files_%s.txt" % FILE_SUFFIX_REGEX)
|
||||
finally:
|
||||
for o in objs:
|
||||
o.delete()
|
||||
|
@ -770,7 +770,7 @@ class FileFieldStorageTests(TestCase):
|
|||
# Testing truncation.
|
||||
names = [o.limited_length.name for o in objs]
|
||||
self.assertEqual(names[0], 'tests/%s' % filename)
|
||||
six.assertRegex(self, names[1], 'tests/fi_%s.ext' % FILE_SUFFIX_REGEX)
|
||||
self.assertRegex(names[1], 'tests/fi_%s.ext' % FILE_SUFFIX_REGEX)
|
||||
|
||||
# Testing exception is raised when filename is too short to truncate.
|
||||
filename = 'short.longext'
|
||||
|
@ -879,7 +879,7 @@ class SlowFile(ContentFile):
|
|||
return super(ContentFile, self).chunks()
|
||||
|
||||
|
||||
class FileSaveRaceConditionTest(unittest.TestCase):
|
||||
class FileSaveRaceConditionTest(SimpleTestCase):
|
||||
def setUp(self):
|
||||
self.storage_dir = tempfile.mkdtemp()
|
||||
self.storage = FileSystemStorage(self.storage_dir)
|
||||
|
@ -897,7 +897,7 @@ class FileSaveRaceConditionTest(unittest.TestCase):
|
|||
self.thread.join()
|
||||
files = sorted(os.listdir(self.storage_dir))
|
||||
self.assertEqual(files[0], 'conflict')
|
||||
six.assertRegex(self, files[1], 'conflict_%s' % FILE_SUFFIX_REGEX)
|
||||
self.assertRegex(files[1], 'conflict_%s' % FILE_SUFFIX_REGEX)
|
||||
|
||||
|
||||
@unittest.skipIf(sys.platform.startswith('win'), "Windows only partially supports umasks and chmod.")
|
||||
|
@ -940,7 +940,7 @@ class FileStoragePermissions(unittest.TestCase):
|
|||
self.assertEqual(dir_mode, 0o777 & ~self.umask)
|
||||
|
||||
|
||||
class FileStoragePathParsing(unittest.TestCase):
|
||||
class FileStoragePathParsing(SimpleTestCase):
|
||||
def setUp(self):
|
||||
self.storage_dir = tempfile.mkdtemp()
|
||||
self.storage = FileSystemStorage(self.storage_dir)
|
||||
|
@ -961,7 +961,7 @@ class FileStoragePathParsing(unittest.TestCase):
|
|||
files = sorted(os.listdir(os.path.join(self.storage_dir, 'dotted.path')))
|
||||
self.assertFalse(os.path.exists(os.path.join(self.storage_dir, 'dotted_.path')))
|
||||
self.assertEqual(files[0], 'test')
|
||||
six.assertRegex(self, files[1], 'test_%s' % FILE_SUFFIX_REGEX)
|
||||
self.assertRegex(files[1], 'test_%s' % FILE_SUFFIX_REGEX)
|
||||
|
||||
def test_first_character_dot(self):
|
||||
"""
|
||||
|
@ -974,7 +974,7 @@ class FileStoragePathParsing(unittest.TestCase):
|
|||
files = sorted(os.listdir(os.path.join(self.storage_dir, 'dotted.path')))
|
||||
self.assertFalse(os.path.exists(os.path.join(self.storage_dir, 'dotted_.path')))
|
||||
self.assertEqual(files[0], '.test')
|
||||
six.assertRegex(self, files[1], '.test_%s' % FILE_SUFFIX_REGEX)
|
||||
self.assertRegex(files[1], '.test_%s' % FILE_SUFFIX_REGEX)
|
||||
|
||||
|
||||
class ContentFileStorageTestCase(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue