summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorlucasesposito <espositolucas95@gmail.com>2024-08-07 03:45:16 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-08-09 12:27:15 +0200
commitf16a9a556fb4225f9094048614f4fcec3db7e067 (patch)
tree1d32ad9b846d90aca27b323a0caafeb7b730b611 /tests
parent69aa13ffb92f6a7c62661c616a8c7b0f515ea43d (diff)
Fixed #35658 -- Initialized InMemoryFileNode instances with a name.
Diffstat (limited to 'tests')
-rw-r--r--tests/file_storage/tests.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
index c7ca873521..b486578cdb 100644
--- a/tests/file_storage/tests.py
+++ b/tests/file_storage/tests.py
@@ -1024,6 +1024,23 @@ class FileFieldStorageTests(TestCase):
with temp_storage.open("tests/stringio") as f:
self.assertEqual(f.read(), b"content")
+ @override_settings(
+ STORAGES={
+ DEFAULT_STORAGE_ALIAS: {
+ "BACKEND": "django.core.files.storage.InMemoryStorage"
+ }
+ }
+ )
+ def test_create_file_field_from_another_file_field_in_memory_storage(self):
+ f = ContentFile("content", "file.txt")
+ obj = Storage.objects.create(storage_callable_default=f)
+ new_obj = Storage.objects.create(
+ storage_callable_default=obj.storage_callable_default.file
+ )
+ storage = callable_default_storage()
+ with storage.open(new_obj.storage_callable_default.name) as f:
+ self.assertEqual(f.read(), b"content")
+
class FieldCallableFileStorageTests(SimpleTestCase):
def setUp(self):