summaryrefslogtreecommitdiff
path: root/tests/check_framework
diff options
context:
space:
mode:
Diffstat (limited to 'tests/check_framework')
-rw-r--r--tests/check_framework/test_urls.py41
-rw-r--r--tests/check_framework/urls/path_compatibility/matched_angle_brackets.py5
-rw-r--r--tests/check_framework/urls/path_compatibility/unmatched_angle_brackets.py8
3 files changed, 54 insertions, 0 deletions
diff --git a/tests/check_framework/test_urls.py b/tests/check_framework/test_urls.py
index a9038c6f13..4b6a4a6f3e 100644
--- a/tests/check_framework/test_urls.py
+++ b/tests/check_framework/test_urls.py
@@ -161,6 +161,47 @@ class CheckUrlConfigTests(SimpleTestCase):
],
)
+ @override_settings(
+ ROOT_URLCONF="check_framework.urls.path_compatibility.matched_angle_brackets"
+ )
+ def test_no_warnings_matched_angle_brackets(self):
+ self.assertEqual(check_url_config(None), [])
+
+ @override_settings(
+ ROOT_URLCONF="check_framework.urls.path_compatibility.unmatched_angle_brackets"
+ )
+ def test_warning_unmatched_angle_brackets(self):
+ self.assertEqual(
+ check_url_config(None),
+ [
+ Warning(
+ "Your URL pattern 'beginning-with/<angle_bracket' has an unmatched "
+ "'<' bracket.",
+ id="urls.W010",
+ ),
+ Warning(
+ "Your URL pattern 'ending-with/angle_bracket>' has an unmatched "
+ "'>' bracket.",
+ id="urls.W010",
+ ),
+ Warning(
+ "Your URL pattern 'closed_angle>/x/<opened_angle' has an unmatched "
+ "'>' bracket.",
+ id="urls.W010",
+ ),
+ Warning(
+ "Your URL pattern 'closed_angle>/x/<opened_angle' has an unmatched "
+ "'<' bracket.",
+ id="urls.W010",
+ ),
+ Warning(
+ "Your URL pattern '<mixed>angle_bracket>' has an unmatched '>' "
+ "bracket.",
+ id="urls.W010",
+ ),
+ ],
+ )
+
class UpdatedToPathTests(SimpleTestCase):
@override_settings(
diff --git a/tests/check_framework/urls/path_compatibility/matched_angle_brackets.py b/tests/check_framework/urls/path_compatibility/matched_angle_brackets.py
new file mode 100644
index 0000000000..de3076942d
--- /dev/null
+++ b/tests/check_framework/urls/path_compatibility/matched_angle_brackets.py
@@ -0,0 +1,5 @@
+from django.urls import path
+
+urlpatterns = [
+ path("<int:angle_bracket>", lambda x: x),
+]
diff --git a/tests/check_framework/urls/path_compatibility/unmatched_angle_brackets.py b/tests/check_framework/urls/path_compatibility/unmatched_angle_brackets.py
new file mode 100644
index 0000000000..e53685ec7a
--- /dev/null
+++ b/tests/check_framework/urls/path_compatibility/unmatched_angle_brackets.py
@@ -0,0 +1,8 @@
+from django.urls import path
+
+urlpatterns = [
+ path("beginning-with/<angle_bracket", lambda x: x),
+ path("ending-with/angle_bracket>", lambda x: x),
+ path("closed_angle>/x/<opened_angle", lambda x: x),
+ path("<mixed>angle_bracket>", lambda x: x),
+]