1
0
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:
Simon Charette
2024-08-09 13:03:24 -04:00
committed by nessita
parent 39abd56a7f
commit 57307bbc7d
16 changed files with 84 additions and 39 deletions

View File

@@ -583,8 +583,9 @@ class ManyToManyTests(TestCase):
"get_prefetch_queryset() is deprecated. Use get_prefetch_querysets() "
"instead."
)
with self.assertWarnsMessage(RemovedInDjango60Warning, msg):
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
self.a1.publications.get_prefetch_queryset(articles)
self.assertEqual(ctx.filename, __file__)
def test_get_prefetch_querysets_invalid_querysets_length(self):
articles = Article.objects.all()