mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #35666 -- Documented stacklevel usage and testing, and adjusted test suite accordingly.
Over the years we've had multiple instances of hit and misses when emitting warnings: either setting the wrong stacklevel or not setting it at all. This work adds assertions for the existing warnings that were declaring the correct stacklevel, but were lacking tests for it.
This commit is contained in:
@@ -2022,13 +2022,15 @@ class DeprecationTests(TestCase):
|
||||
"get_current_querysets() instead."
|
||||
)
|
||||
authors = Author.objects.all()
|
||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg):
|
||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
|
||||
self.assertEqual(
|
||||
Prefetch("authors", authors).get_current_queryset(1),
|
||||
authors,
|
||||
)
|
||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg):
|
||||
self.assertEqual(ctx.filename, __file__)
|
||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
|
||||
self.assertIsNone(Prefetch("authors").get_current_queryset(1))
|
||||
self.assertEqual(ctx.filename, __file__)
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango60Warning)
|
||||
def test_prefetch_one_level_fallback(self):
|
||||
|
||||
Reference in New Issue
Block a user