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

Fixed 36622 -- Prevented LazyObject FileField storages from evaluating at boot time.

Co-authored-by: Fabien MICHEL <fmichel@adista.fr>
This commit is contained in:
Clifford Gama
2025-10-09 21:24:06 +02:00
committed by nessita
parent 2b62951fec
commit 6862d46dd9
3 changed files with 17 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ from django.test.utils import requires_tz_support
from django.urls import NoReverseMatch, reverse_lazy
from django.utils import timezone
from django.utils._os import symlinks_supported
from django.utils.functional import empty
from .models import (
Storage,
@@ -1267,3 +1268,11 @@ class StorageHandlerTests(SimpleTestCase):
)
with self.assertRaisesMessage(InvalidStorageError, msg):
test_storages["invalid_backend"]
class StorageLazyObjectTests(SimpleTestCase):
def test_lazy_object_is_not_evaluated_before_manual_access(self):
obj = Storage()
self.assertIs(obj.lazy_storage.storage._wrapped, empty)
# assertEqual triggers resolution.
self.assertEqual(obj.lazy_storage.storage, temp_storage)