Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwojcik committed Nov 10, 2024
1 parent b5c234a commit b90c334
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions testproject/testapp/tests/test_urls/test_urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import pathlib
import re

import pytest
from deepdiff import DeepDiff
Expand All @@ -15,15 +16,21 @@ def test_urls_have_not_changed(settings):
FILE_PATH = TEST_PATH / "urls_snapshot.json"
url_patterns = get_resolver().url_patterns

# Function to normalize URL patterns by removing trailing \Z
# otherwise fails in CI
def normalize_pattern(pattern):
return re.sub(r"\\Z$", "", pattern)

def get_all_urls(patterns, prefix=""):
urls = []
for pattern in patterns:
if hasattr(pattern, "url_patterns"):
urls += get_all_urls(
pattern.url_patterns, prefix + pattern.pattern.regex.pattern
pattern.url_patterns,
prefix + normalize_pattern(pattern.pattern.regex.pattern),
)
else:
pattern_str = prefix + pattern.pattern.regex.pattern
pattern_str = prefix + normalize_pattern(pattern.pattern.regex.pattern)
name = pattern.name if pattern.name else None
urls.append({"pattern": pattern_str, "name": name})
return urls
Expand Down

0 comments on commit b90c334

Please sign in to comment.