Skip to content

Commit

Permalink
Officially support new Djangoes
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Feb 8, 2024
1 parent 375f994 commit e9d9a94
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 16 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ on: [push]

jobs:
Test:
name: Test with ${{ matrix.py }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
py:
- "3.6"
- "3.10"
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.6
- name: Install
run: |
python -m pip install --upgrade pip
python -m pip install tox
- name: Test with tox
run: tox
python-version: ${{ matrix.py }}
cache: pip
- run: python -m pip install tox tox-gh
- run: tox
Lint:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion django_urr/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.utils.functional import cached_property
from django.utils.regex_helper import normalize

try: # Django 2.0
try: # Django 2.0+
url_resolver_types = (urls.URLResolver,)
DJANGO_2 = True
except AttributeError: # Django 1.11
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dynamic = ["version"]
description = "URL resolver utilities for Django"
readme = "README.md"
license = "MIT"
requires-python = ">=3.6"
authors = [
{ name = "Valohai", email = "[email protected]" },
]
Expand All @@ -18,6 +19,9 @@ dependencies = [
"Django",
]

[project.optional-dependencies]
test = ["pytest>=6.0", "pytest-django"]

[project.urls]
Homepage = "https://github.com/valohai/django-urr"

Expand All @@ -30,7 +34,7 @@ include = [
]

[tool.pytest.ini_options]
django_settings_module = "urrtests.settings"
DJANGO_SETTINGS_MODULE = "urrtests.settings"
norecursedirs = [".git", ".tox"]

[tool.ruff]
Expand Down
15 changes: 12 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
[tox]
envlist = py36-django{111,2,3}
envlist =
py36-django{111,2,3}
py310-django{32,42,50}

[testenv]
commands = py.test -v urrtests
extras = test
deps =
pytest>=3.0.0
pytest-django>=3.0.0
django111: django~=1.11
django2: django~=2.0
django3: django~=3.0
django32: django~=3.2
django42: django~=4.2
django50: django~=5.0

[gh]
python =
3.10 = py310
3.6 = py36
2 changes: 2 additions & 0 deletions urrtests/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ def test_named_groups(urls_by_qname):

def test_merged_pattern(urls_by_qname):
assert urls_by_qname["admin:auth_user_change"].merged_pattern in (
r"admin/auth/user/(?P<object_id>.+)/change/\Z", # Django 3.2+
r"admin\/auth\/user\/(?P<object_id>.+)\/change\/", # Django 2
r"admin/auth/user/(.+)/change/", # Django 1.11
)
assert urls_by_qname["test1"].merged_pattern in (
r"test1/(?P<a>[^/]+)/(?P<b>[^/]+)/(?P<c>[0-9]+)/\Z", # Django 3.2+
r"test1\/(?P<a>[^/]+)\/(?P<b>[^/]+)\/(?P<c>[0-9]+)\/", # Django 2
r"test1/(?P<a>.+?)/(?P<b>.+?)/(?P<c>[0-9]+?)/", # Django 1.11
)
Expand Down
3 changes: 2 additions & 1 deletion urrtests/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.conf.urls import url
from django.contrib import admin

from urrtests.views import test_view
Expand All @@ -14,6 +13,8 @@
re_path(r"test3/(.+?)/(.+?)/(\d+?)/", test_view, name="test3"),
]
except ImportError: # Django 1.11
from django.conf.urls import url

urlpatterns = [
url("admin/", admin.site.urls),
url("unnamed/(?P<a>.+?)/(?P<b>.+?)/", test_view),
Expand Down

0 comments on commit e9d9a94

Please sign in to comment.