[5.1.x] 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.

Backport of 57307bbc7d from main.
This commit is contained in:
Simon Charette 2024-08-09 13:03:24 -04:00 committed by Natalia
parent dd58edcc37
commit 9a461cae3e
16 changed files with 84 additions and 39 deletions

View file

@ -328,5 +328,6 @@ class ChoicesMetaDeprecationTests(SimpleTestCase):
from django.db.models import enums
msg = "ChoicesMeta is deprecated in favor of ChoicesType."
with self.assertWarnsMessage(RemovedInDjango60Warning, msg):
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
enums.ChoicesMeta
self.assertEqual(ctx.filename, __file__)