diff options
| author | Amir Karimi <amk9978@gmail.com> | 2023-07-04 17:09:09 +0330 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-07-11 11:59:27 +0200 |
| commit | d1855c4847215f3afe3708736be13388bb6437eb (patch) | |
| tree | 26a006f50f57ef468eb3858877f3907ed429f459 /tests/check_framework | |
| parent | 2ddfa3e2b63d7a77270711dbe63aafb86abf4ddd (diff) | |
Fixed #34691 -- Added system check for unmatched angle brackets in path().
Diffstat (limited to 'tests/check_framework')
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), +] |
