Skip to content

feat(integrations): Support Django 5.1 #3207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jul 17, 2024
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
Loading