1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

[6.0.x] Fixed 36622 -- Prevented LazyObject FileField storages from evaluating at boot time.

Co-authored-by: Fabien MICHEL <fmichel@adista.fr>

Backport of 6862d46dd9 from main.
This commit is contained in:
Clifford Gama
2025-10-09 21:24:06 +02:00
committed by Natalia
parent 094797ae50
commit 5c114ce2d8
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)