Skip to content

Commit be166d9

Browse files
committed
Python: Expand Django 2/3 routing tests with 1.x way
Added it to the `testapp` so it's easy to run the server to SEE that it works. Added it to `routing_test` so it's obvious this is supported by our modeling when we _know_ it's running Django 2/3.
1 parent ae60ac2 commit be166d9

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

python/ql/test/experimental/library-tests/frameworks/django-v2-v3/routing_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,13 @@ def not_valid_identifier(request): # $routeHandler
9797
# We should not report there is a request parameter called `not_valid!`
9898
path("not_valid/<not_valid!>", not_valid_identifier), # $routeSetup="not_valid/<not_valid!>"
9999
]
100+
101+
# This version 1.x way of defining urls is deprecated in Django 3.1, but still works
102+
from django.conf.urls import url
103+
104+
def deprecated(request): # $f-:routeHandler
105+
return HttpResponse('deprecated')
106+
107+
urlpatterns = [
108+
url(r"^deprecated/", deprecated), # $f-:routeSetup="^deprecated/"
109+
]

python/ql/test/experimental/library-tests/frameworks/django-v2-v3/testapp/urls.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from django.urls import path, re_path
22

3+
# This version 1.x way of defining urls is deprecated in Django 3.1, but still works
4+
from django.conf.urls import url
5+
36
from . import views
47

58
urlpatterns = [
@@ -8,4 +11,5 @@
811
# inline expectation tests (which thinks the `$` would mark the beginning of a new
912
# line)
1013
re_path(r"^ba[rz]/", views.bar_baz), # $routeSetup="^ba[rz]/"
14+
url(r"^deprecated/", views.deprecated), # $f-routeSetup="^deprecated/"
1115
]

python/ql/test/experimental/library-tests/frameworks/django-v2-v3/testapp/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ def foo(request: HttpRequest): # $routeHandler
55

66
def bar_baz(request: HttpRequest): # $routeHandler
77
return HttpResponse("bar_baz")
8+
9+
def deprecated(request: HttpRequest): # $f-:routeHandler
10+
return HttpResponse("deprecated")

0 commit comments

Comments
 (0)