1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #34192 -- Preserved callable storage when it returns default_storage.

This commit is contained in:
Matt Westcott
2023-01-20 18:10:29 +00:00
committed by Mariusz Felisiak
parent e3a4cee081
commit ef85b6bf0b
3 changed files with 27 additions and 4 deletions

View File

@@ -41,7 +41,13 @@ from django.utils import timezone
from django.utils._os import symlinks_supported
from django.utils.deprecation import RemovedInDjango51Warning
from .models import Storage, callable_storage, temp_storage, temp_storage_location
from .models import (
Storage,
callable_default_storage,
callable_storage,
temp_storage,
temp_storage_location,
)
FILE_SUFFIX_REGEX = "[A-Za-z0-9]{7}"
@@ -1018,6 +1024,15 @@ class FieldCallableFileStorageTests(SimpleTestCase):
storage = kwargs["storage"]
self.assertIs(storage, callable_storage)
def test_deconstruction_storage_callable_default(self):
"""
A callable that returns default_storage is not omitted when
deconstructing.
"""
obj = Storage()
*_, kwargs = obj._meta.get_field("storage_callable_default").deconstruct()
self.assertIs(kwargs["storage"], callable_default_storage)
# Tests for a race condition on file saving (#4948).
# This is written in such a way that it'll always pass on platforms