Skip to content

Commit

Permalink
feat(integrations): Support Django 5.1 (#3207)
Browse files Browse the repository at this point in the history
Co-authored-by: Christian Clauss <cclauss@me.com>
  • Loading branch information
sentrivana and cclauss committed Jul 17, 2024
1 parent 76c9c76 commit 5e1f44b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
2 changes: 0 additions & 2 deletions scripts/runtox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ done

searchstring="$1"

export TOX_PARALLEL_NO_SPINNER=1

if $excludelatest; then
echo "Excluding latest"
ENV="$($TOXPATH -l | grep -- "$searchstring" | grep -v -- '-latest' | tr $'\n' ',')"
Expand Down
25 changes: 24 additions & 1 deletion tests/integrations/django/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,35 @@ def test_resolver_path_multiple_groups():
django.VERSION < (2, 0),
reason="Django>=2.0 required for <converter:parameter> patterns",
)
@pytest.mark.skipif(
django.VERSION > (5, 1),
reason="get_converter removed in 5.1",
)
def test_resolver_path_complex_path_legacy():
class CustomPathConverter(PathConverter):
regex = r"[^/]+(/[^/]+){0,2}"

with mock.patch(
"django.urls.resolvers.get_converter",
return_value=CustomPathConverter,
):
url_conf = (path("api/v3/<custom_path:my_path>", lambda x: ""),)
resolver = RavenResolver()
result = resolver.resolve("/api/v3/abc/def/ghi", url_conf)
assert result == "/api/v3/{my_path}"


@pytest.mark.skipif(
django.VERSION < (5, 1),
reason="get_converters is used in 5.1",
)
def test_resolver_path_complex_path():
class CustomPathConverter(PathConverter):
regex = r"[^/]+(/[^/]+){0,2}"

with mock.patch(
"django.urls.resolvers.get_converter", return_value=CustomPathConverter
"django.urls.resolvers.get_converters",
return_value={"custom_path": CustomPathConverter},
):
url_conf = (path("api/v3/<custom_path:my_path>", lambda x: ""),)
resolver = RavenResolver()
Expand Down
13 changes: 7 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ envlist =
# - Django 4.x
{py3.8,py3.11,py3.12}-django-v{4.0,4.1,4.2}
# - Django 5.x
{py3.10,py3.11,py3.12}-django-v{5.0}
{py3.10,py3.11,py3.12}-django-v{5.0,5.1}
{py3.10,py3.11,py3.12}-django-latest

# Falcon
Expand Down Expand Up @@ -374,13 +374,13 @@ deps =
# Django
django: psycopg2-binary
django-v{1.11,2.0,2.1,2.2,3.0,3.1,3.2}: djangorestframework>=3.0.0,<4.0.0
django-v{2.0,2.2,3.0,3.2,4.0,4.1,4.2,5.0}: channels[daphne]
django-v{2.0,2.2,3.0,3.2,4.0,4.1,4.2,5.0,5.1}: channels[daphne]
django-v{1.11,2.0,2.2,3.0,3.2}: Werkzeug<2.1.0
django-v{1.11,2.0,2.2,3.0}: pytest-django<4.0
django-v{3.2,4.0,4.1,4.2,5.0}: pytest-django
django-v{4.0,4.1,4.2,5.0}: djangorestframework
django-v{4.0,4.1,4.2,5.0}: pytest-asyncio
django-v{4.0,4.1,4.2,5.0}: Werkzeug
django-v{3.2,4.0,4.1,4.2,5.0,5.1}: pytest-django
django-v{4.0,4.1,4.2,5.0,5.1}: djangorestframework
django-v{4.0,4.1,4.2,5.0,5.1}: pytest-asyncio
django-v{4.0,4.1,4.2,5.0,5.1}: Werkzeug
django-latest: djangorestframework
django-latest: pytest-asyncio
django-latest: pytest-django
Expand All @@ -396,6 +396,7 @@ deps =
django-v4.1: Django~=4.1.0
django-v4.2: Django~=4.2.0
django-v5.0: Django~=5.0.0
django-v5.1: Django==5.1b1
django-latest: Django

# Falcon
Expand Down

0 comments on commit 5e1f44b

Please sign in to comment.