1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Removed unnecessary bytes prefix for ContentFile

This commit is contained in:
Claude Paroz
2012-08-29 10:00:29 +02:00
parent 361d6738f8
commit b5240d25c1
2 changed files with 27 additions and 27 deletions

View File

@@ -20,7 +20,7 @@ class FileStorageTests(TestCase):
shutil.rmtree(temp_storage_location)
def test_files(self):
temp_storage.save('tests/default.txt', ContentFile(b'default content'))
temp_storage.save('tests/default.txt', ContentFile('default content'))
# Attempting to access a FileField from the class raises a descriptive
# error
self.assertRaises(AttributeError, lambda: Storage.normal)
@@ -31,7 +31,7 @@ class FileStorageTests(TestCase):
self.assertRaises(ValueError, lambda: obj1.normal.size)
# Saving a file enables full functionality.
obj1.normal.save("django_test.txt", ContentFile(b"content"))
obj1.normal.save("django_test.txt", ContentFile("content"))
self.assertEqual(obj1.normal.name, "tests/django_test.txt")
self.assertEqual(obj1.normal.size, 7)
self.assertEqual(obj1.normal.read(), b"content")
@@ -59,7 +59,7 @@ class FileStorageTests(TestCase):
# Save another file with the same name.
obj2 = Storage()
obj2.normal.save("django_test.txt", ContentFile(b"more content"))
obj2.normal.save("django_test.txt", ContentFile("more content"))
self.assertEqual(obj2.normal.name, "tests/django_test_1.txt")
self.assertEqual(obj2.normal.size, 12)
@@ -70,13 +70,13 @@ class FileStorageTests(TestCase):
# Deleting an object does not delete the file it uses.
obj2.delete()
obj2.normal.save("django_test.txt", ContentFile(b"more content"))
obj2.normal.save("django_test.txt", ContentFile("more content"))
self.assertEqual(obj2.normal.name, "tests/django_test_2.txt")
# Multiple files with the same name get _N appended to them.
objs = [Storage() for i in range(3)]
for o in objs:
o.normal.save("multiple_files.txt", ContentFile(b"Same Content"))
o.normal.save("multiple_files.txt", ContentFile("Same Content"))
self.assertEqual(
[o.normal.name for o in objs],
["tests/multiple_files.txt", "tests/multiple_files_1.txt", "tests/multiple_files_2.txt"]
@@ -100,7 +100,7 @@ class FileStorageTests(TestCase):
# Verify the fix for #5655, making sure the directory is only
# determined once.
obj4 = Storage()
obj4.random.save("random_file", ContentFile(b"random content"))
obj4.random.save("random_file", ContentFile("random content"))
self.assertTrue(obj4.random.name.endswith("/random_file"))
def test_max_length(self):