mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Python: Handle django v4 as well in tests
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
from django.urls import path, re_path
|
||||
|
||||
# This version 1.x way of defining urls is deprecated in Django 3.1, but still works
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
@@ -11,7 +8,6 @@ urlpatterns = [
|
||||
# inline expectation tests (which thinks the `$` would mark the beginning of a new
|
||||
# line)
|
||||
re_path(r"^ba[rz]/", views.bar_baz), # $routeSetup="^ba[rz]/"
|
||||
url(r"^deprecated/", views.deprecated), # $routeSetup="^deprecated/"
|
||||
|
||||
path("basic-view-handler/", views.MyBasicViewHandler.as_view()), # $routeSetup="basic-view-handler/"
|
||||
path("custom-inheritance-view-handler/", views.MyViewHandlerWithCustomInheritance.as_view()), # $routeSetup="custom-inheritance-view-handler/"
|
||||
@@ -19,3 +15,20 @@ urlpatterns = [
|
||||
path("CustomRedirectView/<foo>", views.CustomRedirectView.as_view()), # $routeSetup="CustomRedirectView/<foo>"
|
||||
path("CustomRedirectView2/<foo>", views.CustomRedirectView2.as_view()), # $routeSetup="CustomRedirectView2/<foo>"
|
||||
]
|
||||
|
||||
from django import __version__ as django_version
|
||||
|
||||
if django_version[0] == "3":
|
||||
# This version 1.x way of defining urls is deprecated in Django 3.1, but still works.
|
||||
# However, it is removed in Django 4.0, so we need this guard to make our code runnable
|
||||
from django.conf.urls import url
|
||||
|
||||
old_urlpatterns = urlpatterns
|
||||
|
||||
# we need this assignment to get our logic working... maybe it should be more
|
||||
# sophisticated?
|
||||
urlpatterns = [
|
||||
url(r"^deprecated/", views.deprecated), # $routeSetup="^deprecated/"
|
||||
]
|
||||
|
||||
urlpatterns += old_urlpatterns
|
||||
|
||||
Reference in New Issue
Block a user