summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/file_storage/tests.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py
index b6d3e1ff0b..6960b1f9f5 100644
--- a/tests/regressiontests/file_storage/tests.py
+++ b/tests/regressiontests/file_storage/tests.py
@@ -40,6 +40,9 @@ except ImportError:
Image = None
+FILE_SUFFIX_REGEX = '[A-Za-z0-9]{7}'
+
+
class GetStorageClassTests(SimpleTestCase):
def test_get_filesystem_storage(self):
@@ -431,10 +434,9 @@ class FileSaveRaceConditionTest(unittest.TestCase):
self.thread.start()
name = self.save_file('conflict')
self.thread.join()
- self.assertTrue(self.storage.exists('conflict'))
- self.assertTrue(self.storage.exists('conflict_1'))
- self.storage.delete('conflict')
- self.storage.delete('conflict_1')
+ files = sorted(os.listdir(self.storage_dir))
+ self.assertEqual(files[0], 'conflict')
+ six.assertRegex(self, files[1], 'conflict_%s' % FILE_SUFFIX_REGEX)
@unittest.skipIf(sys.platform.startswith('win'), "Windows only partially supports umasks and chmod.")
class FileStoragePermissions(unittest.TestCase):
@@ -478,9 +480,10 @@ class FileStoragePathParsing(unittest.TestCase):
self.storage.save('dotted.path/test', ContentFile("1"))
self.storage.save('dotted.path/test', ContentFile("2"))
+ 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.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/test')))
- self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/test_1')))
+ self.assertEqual(files[0], 'test')
+ six.assertRegex(self, files[1], 'test_%s' % FILE_SUFFIX_REGEX)
def test_first_character_dot(self):
"""
@@ -490,8 +493,10 @@ class FileStoragePathParsing(unittest.TestCase):
self.storage.save('dotted.path/.test', ContentFile("1"))
self.storage.save('dotted.path/.test', ContentFile("2"))
- self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/.test')))
- self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/.test_1')))
+ 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)
class DimensionClosingBug(unittest.TestCase):
"""