summaryrefslogtreecommitdiff
path: root/tests/urlpatterns/tests.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2024-08-09 13:03:24 -0400
committerNatalia <124304+nessita@users.noreply.github.com>2024-08-28 11:47:15 -0300
commit9a461cae3e5536cbacafa53dbd290ff68df22e67 (patch)
tree7aea2bcfc8b8fd339341aa5c7cb6143a3b99d858 /tests/urlpatterns/tests.py
parentdd58edcc373afe57a56bf7c2374a4fc8446e80e9 (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/urlpatterns/tests.py')
-rw-r--r--tests/urlpatterns/tests.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/urlpatterns/tests.py b/tests/urlpatterns/tests.py
index 78b71fe325..6c8d6470c0 100644
--- a/tests/urlpatterns/tests.py
+++ b/tests/urlpatterns/tests.py
@@ -212,10 +212,11 @@ class SimplifiedURLTests(SimpleTestCase):
"converters is deprecated and will be removed in Django 6.0."
)
try:
- with self.assertWarnsMessage(RemovedInDjango60Warning, msg):
+ with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
register_converter(IntConverter, "int")
finally:
REGISTERED_CONVERTERS.pop("int", None)
+ self.assertEqual(ctx.filename, __file__)
def test_warning_override_converter(self):
# RemovedInDjango60Warning: when the deprecation ends, replace with
@@ -226,11 +227,12 @@ class SimplifiedURLTests(SimpleTestCase):
"registered converters is deprecated and will be removed in Django 6.0."
)
try:
- with self.assertWarnsMessage(RemovedInDjango60Warning, msg):
+ with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
register_converter(Base64Converter, "base64")
register_converter(Base64Converter, "base64")
finally:
REGISTERED_CONVERTERS.pop("base64", None)
+ self.assertEqual(ctx.filename, __file__)
def test_invalid_view(self):
msg = "view must be a callable or a list/tuple in the case of include()."