mirror of
https://github.com/django/django.git
synced 2025-01-03 06:55:47 +00:00
Refs #35405 -- Adjusted deprecation warning stacklevel in FieldCacheMixin.get_cache_name().
This commit is contained in:
parent
47f18a7226
commit
39abd56a7f
@ -28,6 +28,7 @@ class FieldCacheMixin:
|
|||||||
f"Override {self.__class__.__qualname__}.cache_name instead of "
|
f"Override {self.__class__.__qualname__}.cache_name instead of "
|
||||||
"get_cache_name().",
|
"get_cache_name().",
|
||||||
RemovedInDjango60Warning,
|
RemovedInDjango60Warning,
|
||||||
|
stacklevel=3,
|
||||||
)
|
)
|
||||||
return cache_name
|
return cache_name
|
||||||
|
|
||||||
|
@ -27,3 +27,7 @@ Bugfixes
|
|||||||
* Adjusted the deprecation warning ``stacklevel`` when using ``OS_OPEN_FLAGS``
|
* Adjusted the deprecation warning ``stacklevel`` when using ``OS_OPEN_FLAGS``
|
||||||
in :class:`~django.core.files.storage.FileSystemStorage` to correctly point
|
in :class:`~django.core.files.storage.FileSystemStorage` to correctly point
|
||||||
to the offending call site (:ticket:`35326`).
|
to the offending call site (:ticket:`35326`).
|
||||||
|
|
||||||
|
* Adjusted the deprecation warning ``stacklevel`` in
|
||||||
|
``FieldCacheMixin.get_cache_name()`` to correctly point to the offending call
|
||||||
|
site (:ticket:`35405`).
|
||||||
|
@ -34,9 +34,10 @@ class FieldCacheMixinTests(SimpleTestCase):
|
|||||||
# RemovedInDjango60Warning.
|
# RemovedInDjango60Warning.
|
||||||
def test_get_cache_name_deprecated(self):
|
def test_get_cache_name_deprecated(self):
|
||||||
msg = "Override ExampleOld.cache_name instead of get_cache_name()."
|
msg = "Override ExampleOld.cache_name instead of get_cache_name()."
|
||||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg):
|
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
|
||||||
result = ExampleOld().cache_name
|
result = ExampleOld().cache_name
|
||||||
self.assertEqual(result, "example")
|
self.assertEqual(result, "example")
|
||||||
|
self.assertEqual(ctx.filename, __file__)
|
||||||
|
|
||||||
def test_cache_name(self):
|
def test_cache_name(self):
|
||||||
result = Example().cache_name
|
result = Example().cache_name
|
||||||
|
Loading…
Reference in New Issue
Block a user