diff options
| author | Simon Charette <charette.s@gmail.com> | 2024-08-09 13:03:24 -0400 |
|---|---|---|
| committer | Natalia <124304+nessita@users.noreply.github.com> | 2024-08-28 11:47:15 -0300 |
| commit | 9a461cae3e5536cbacafa53dbd290ff68df22e67 (patch) | |
| tree | 7aea2bcfc8b8fd339341aa5c7cb6143a3b99d858 /tests/contenttypes_tests | |
| parent | dd58edcc373afe57a56bf7c2374a4fc8446e80e9 (diff) | |
[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 57307bbc7d88927989cf5b314f16d6e13ade04e6 from main.
Diffstat (limited to 'tests/contenttypes_tests')
| -rw-r--r-- | tests/contenttypes_tests/test_fields.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/contenttypes_tests/test_fields.py b/tests/contenttypes_tests/test_fields.py index 15f1dafd63..ab16324fb6 100644 --- a/tests/contenttypes_tests/test_fields.py +++ b/tests/contenttypes_tests/test_fields.py @@ -98,8 +98,9 @@ class GetPrefetchQuerySetDeprecation(TestCase): "get_prefetch_queryset() is deprecated. Use get_prefetch_querysets() " "instead." ) - with self.assertWarnsMessage(RemovedInDjango60Warning, msg): + with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx: questions[0].answer_set.get_prefetch_queryset(questions) + self.assertEqual(ctx.filename, __file__) def test_generic_foreign_key_warning(self): answers = Answer.objects.all() @@ -107,8 +108,9 @@ class GetPrefetchQuerySetDeprecation(TestCase): "get_prefetch_queryset() is deprecated. Use get_prefetch_querysets() " "instead." ) - with self.assertWarnsMessage(RemovedInDjango60Warning, msg): + with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx: Answer.question.get_prefetch_queryset(answers) + self.assertEqual(ctx.filename, __file__) class GetPrefetchQuerySetsTests(TestCase): |
