diff --git a/testproject/testapp/tests/test_urls/test_urls.py b/testproject/testapp/tests/test_urls/test_urls.py index 39195e35..8bc4add8 100644 --- a/testproject/testapp/tests/test_urls/test_urls.py +++ b/testproject/testapp/tests/test_urls/test_urls.py @@ -1,6 +1,5 @@ import json import pathlib -import re import pytest from deepdiff import DeepDiff @@ -19,12 +18,8 @@ def test_urls_have_not_changed(settings): # Function to normalize URL patterns by removing trailing \Z # otherwise fails in CI def normalize_pattern(pattern): - # Remove trailing \Z - pattern = re.sub(r"\\Z$", "", pattern) - # Remove any format suffixes by identifying "format" capture groups, with or without leading period # noqa: E501 - pattern = re.sub( - r"\(\?P\\?\.[a-z0-9]+\(\?/?\)?\)", "", pattern - ) # noqa: E501 + if pattern.endswith("/?$"): + pattern = pattern[: -len("/?$")] + r"\Z" return pattern def get_all_urls(patterns, prefix=""): diff --git a/testproject/testapp/tests/test_urls/urls_snapshot.json b/testproject/testapp/tests/test_urls/urls_snapshot.json index 7ebdf2a3..c809913d 100644 --- a/testproject/testapp/tests/test_urls/urls_snapshot.json +++ b/testproject/testapp/tests/test_urls/urls_snapshot.json @@ -1,10 +1,10 @@ [ { - "pattern": "^auth/^", + "pattern": "^auth/^(?P\\.[a-z0-9]+/?)\\Z", "name": "api-root" }, { - "pattern": "^auth/^(?P\\.[a-z0-9]+/?)", + "pattern": "^auth/^\\Z", "name": "api-root" }, { @@ -24,11 +24,11 @@ "name": "provider-auth" }, { - "pattern": "^auth/^token/login/?$", + "pattern": "^auth/^token/login\\Z", "name": "login" }, { - "pattern": "^auth/^token/logout/?$", + "pattern": "^auth/^token/logout\\Z", "name": "logout" }, { @@ -40,7 +40,7 @@ "name": "user-detail" }, { - "pattern": "^auth/^users/(?P[^/.]+)\\.(?P[a-z0-9]+)/?$", + "pattern": "^auth/^users/(?P[^/.]+)\\.(?P[a-z0-9]+)\\Z", "name": "user-detail" }, { @@ -48,7 +48,7 @@ "name": "user-activation" }, { - "pattern": "^auth/^users/activation\\.(?P[a-z0-9]+)/?$", + "pattern": "^auth/^users/activation\\.(?P[a-z0-9]+)\\Z", "name": "user-activation" }, { @@ -56,7 +56,7 @@ "name": "user-me" }, { - "pattern": "^auth/^users/me\\.(?P[a-z0-9]+)/?$", + "pattern": "^auth/^users/me\\.(?P[a-z0-9]+)\\Z", "name": "user-me" }, { @@ -64,7 +64,7 @@ "name": "user-resend-activation" }, { - "pattern": "^auth/^users/resend_activation\\.(?P[a-z0-9]+)/?$", + "pattern": "^auth/^users/resend_activation\\.(?P[a-z0-9]+)\\Z", "name": "user-resend-activation" }, { @@ -72,7 +72,7 @@ "name": "user-reset-password" }, { - "pattern": "^auth/^users/reset_password\\.(?P[a-z0-9]+)/?$", + "pattern": "^auth/^users/reset_password\\.(?P[a-z0-9]+)\\Z", "name": "user-reset-password" }, { @@ -80,7 +80,7 @@ "name": "user-reset-password-confirm" }, { - "pattern": "^auth/^users/reset_password_confirm\\.(?P[a-z0-9]+)/?$", + "pattern": "^auth/^users/reset_password_confirm\\.(?P[a-z0-9]+)\\Z", "name": "user-reset-password-confirm" }, { @@ -88,7 +88,7 @@ "name": "user-reset-username" }, { - "pattern": "^auth/^users/reset_username\\.(?P[a-z0-9]+)/?$", + "pattern": "^auth/^users/reset_username\\.(?P[a-z0-9]+)\\Z", "name": "user-reset-username" }, { @@ -96,7 +96,7 @@ "name": "user-reset-username-confirm" }, { - "pattern": "^auth/^users/reset_username_confirm\\.(?P[a-z0-9]+)/?$", + "pattern": "^auth/^users/reset_username_confirm\\.(?P[a-z0-9]+)\\Z", "name": "user-reset-username-confirm" }, { @@ -104,7 +104,7 @@ "name": "user-set-password" }, { - "pattern": "^auth/^users/set_password\\.(?P[a-z0-9]+)/?$", + "pattern": "^auth/^users/set_password\\.(?P[a-z0-9]+)\\Z", "name": "user-set-password" }, { @@ -112,11 +112,11 @@ "name": "user-set-username" }, { - "pattern": "^auth/^users/set_username\\.(?P[a-z0-9]+)/?$", + "pattern": "^auth/^users/set_username\\.(?P[a-z0-9]+)\\Z", "name": "user-set-username" }, { - "pattern": "^auth/^users\\.(?P[a-z0-9]+)/?$", + "pattern": "^auth/^users\\.(?P[a-z0-9]+)\\Z", "name": "user-list" }, {