From 043bd709425149b8eff3fb821cba5c23aaebd0df Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 7 Dec 2018 17:52:28 -0500 Subject: [PATCH] Updated test URL patterns to use path() and re_path(). --- tests/admin_changelist/urls.py | 4 +- tests/admin_custom_urls/models.py | 4 +- tests/admin_custom_urls/urls.py | 4 +- tests/admin_docs/namespace_urls.py | 10 +- tests/admin_docs/urls.py | 18 +-- tests/admin_inlines/urls.py | 4 +- tests/admin_scripts/urls.py | 6 +- tests/admin_utils/urls.py | 4 +- tests/admin_views/admin.py | 4 +- tests/admin_views/customadmin.py | 4 +- tests/admin_views/test_adminsite.py | 5 +- tests/admin_views/test_multidb.py | 5 +- tests/admin_views/urls.py | 32 ++--- tests/admin_widgets/urls.py | 4 +- tests/auth_tests/test_admin_multidb.py | 5 +- tests/auth_tests/test_views.py | 2 +- tests/auth_tests/urls.py | 91 +++++++------- tests/auth_tests/urls_admin.py | 4 +- tests/auth_tests/urls_custom_user_admin.py | 4 +- tests/check_framework/test_urls.py | 2 +- .../urls/beginning_with_slash.py | 5 +- .../urls/include_with_dollar.py | 4 +- tests/check_framework/urls/name_with_colon.py | 4 +- tests/check_framework/urls/no_warnings.py | 8 +- .../check_framework/urls/no_warnings_i18n.py | 4 +- .../urls/non_unique_namespaces.py | 14 +-- .../check_framework/urls/unique_namespaces.py | 18 +-- .../urls/warning_in_include.py | 6 +- tests/conditional_processing/urls.py | 18 +-- tests/contenttypes_tests/urls.py | 4 +- tests/context_processors/urls.py | 6 +- tests/file_storage/urls.py | 4 +- tests/file_uploads/urls.py | 26 ++-- tests/flatpages_tests/urls.py | 10 +- tests/forms_tests/urls.py | 4 +- tests/generic_inline_admin/urls.py | 4 +- tests/gis_tests/geoadmin/urls.py | 4 +- tests/gis_tests/geoapp/urls.py | 12 +- tests/handlers/tests_custom_error_handlers.py | 4 +- tests/handlers/urls.py | 15 ++- tests/i18n/patterns/urls/default.py | 18 +-- tests/i18n/patterns/urls/disabled.py | 4 +- tests/i18n/patterns/urls/included.py | 4 +- tests/i18n/patterns/urls/namespace.py | 7 +- tests/i18n/patterns/urls/path_unused.py | 4 +- tests/i18n/patterns/urls/wrong.py | 4 +- tests/i18n/patterns/urls/wrong_namespace.py | 4 +- tests/i18n/urls.py | 6 +- tests/i18n/urls_default_unprefixed.py | 8 +- tests/logging_tests/urls.py | 7 +- tests/logging_tests/urls_i18n.py | 4 +- tests/messages_tests/urls.py | 17 +-- tests/middleware/cond_get_urls.py | 4 +- tests/middleware/extra_urls.py | 8 +- tests/middleware/urls.py | 10 +- tests/middleware_exceptions/urls.py | 12 +- tests/project_template/urls.py | 4 +- tests/proxy_models/urls.py | 4 +- tests/redirects_tests/urls.py | 4 +- tests/resolve_url/urls.py | 4 +- tests/servers/urls.py | 20 +-- tests/shortcuts/urls.py | 22 ++-- tests/sitemaps_tests/urls/http.py | 67 ++++++---- tests/sitemaps_tests/urls/https.py | 7 +- tests/sitemaps_tests/urls/index_only.py | 5 +- tests/staticfiles_tests/urls/default.py | 4 +- tests/syndication_tests/urls.py | 40 +++--- tests/template_tests/alternate_urls.py | 6 +- tests/template_tests/urls.py | 20 +-- tests/test_client/urls.py | 78 ++++++------ tests/test_client_regress/urls.py | 70 +++++------ tests/test_utils/tests.py | 7 +- tests/test_utils/urls.py | 6 +- tests/timezones/urls.py | 4 +- tests/urlpatterns/path_urls.py | 3 +- tests/urlpatterns_reverse/erroneous_urls.py | 4 +- tests/urlpatterns_reverse/extra_urls.py | 10 +- .../urlpatterns_reverse/included_app_urls.py | 14 +-- .../included_named_urls.py | 10 +- .../included_named_urls2.py | 8 +- .../included_namespace_urls.py | 22 ++-- .../included_no_kwargs_urls.py | 4 +- tests/urlpatterns_reverse/included_urls.py | 8 +- tests/urlpatterns_reverse/included_urls2.py | 6 +- tests/urlpatterns_reverse/method_view_urls.py | 6 +- tests/urlpatterns_reverse/named_urls.py | 10 +- .../named_urls_conflict.py | 18 +-- tests/urlpatterns_reverse/namespace_urls.py | 54 ++++---- tests/urlpatterns_reverse/nested_urls.py | 10 +- .../urlpatterns_reverse/reverse_lazy_urls.py | 10 +- tests/urlpatterns_reverse/tests.py | 30 ++--- tests/urlpatterns_reverse/urlconf_inner.py | 4 +- tests/urlpatterns_reverse/urlconf_outer.py | 6 +- tests/urlpatterns_reverse/urls.py | 116 +++++++++--------- .../urls_without_handlers.py | 6 +- tests/urlpatterns_reverse/utils.py | 8 +- tests/user_commands/urls.py | 4 +- tests/view_tests/default_urls.py | 4 +- tests/view_tests/generic_urls.py | 16 ++- tests/view_tests/regression_21530_urls.py | 4 +- tests/view_tests/tests/test_debug.py | 12 +- tests/view_tests/tests/test_i18n.py | 2 +- tests/view_tests/urls.py | 67 +++++----- tests/wsgi/urls.py | 6 +- 104 files changed, 692 insertions(+), 673 deletions(-) diff --git a/tests/admin_changelist/urls.py b/tests/admin_changelist/urls.py index 1f553a85a9..be569cdca5 100644 --- a/tests/admin_changelist/urls.py +++ b/tests/admin_changelist/urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import url +from django.urls import path from . import admin urlpatterns = [ - url(r'^admin/', admin.site.urls), + path('admin/', admin.site.urls), ] diff --git a/tests/admin_custom_urls/models.py b/tests/admin_custom_urls/models.py index 1fc30ec18c..8b91383b0f 100644 --- a/tests/admin_custom_urls/models.py +++ b/tests/admin_custom_urls/models.py @@ -33,7 +33,7 @@ class ActionAdmin(admin.ModelAdmin): def get_urls(self): # Add the URL of our custom 'add_view' view to the front of the URLs # list. Remove the existing one(s) first - from django.conf.urls import url + from django.urls import re_path def wrap(view): def wrapper(*args, **kwargs): @@ -45,7 +45,7 @@ class ActionAdmin(admin.ModelAdmin): view_name = '%s_%s_add' % info return [ - url(r'^!add/$', wrap(self.add_view), name=view_name), + re_path('^!add/$', wrap(self.add_view), name=view_name), ] + self.remove_url(view_name) diff --git a/tests/admin_custom_urls/urls.py b/tests/admin_custom_urls/urls.py index b07e1395b9..ade49b3957 100644 --- a/tests/admin_custom_urls/urls.py +++ b/tests/admin_custom_urls/urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import url +from django.urls import path from .models import site urlpatterns = [ - url(r'^admin/', site.urls), + path('admin/', site.urls), ] diff --git a/tests/admin_docs/namespace_urls.py b/tests/admin_docs/namespace_urls.py index d05922c33e..719bf0ddf5 100644 --- a/tests/admin_docs/namespace_urls.py +++ b/tests/admin_docs/namespace_urls.py @@ -1,14 +1,14 @@ -from django.conf.urls import include, url from django.contrib import admin +from django.urls import include, path from . import views backend_urls = ([ - url(r'^something/$', views.XViewClass.as_view(), name='something'), + path('something/', views.XViewClass.as_view(), name='something'), ], 'backend') urlpatterns = [ - url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - url(r'^admin/', admin.site.urls), - url(r'^api/backend/', include(backend_urls, namespace='backend')), + path('admin/doc/', include('django.contrib.admindocs.urls')), + path('admin/', admin.site.urls), + path('api/backend/', include(backend_urls, namespace='backend')), ] diff --git a/tests/admin_docs/urls.py b/tests/admin_docs/urls.py index 67c72b249c..f535afc9f2 100644 --- a/tests/admin_docs/urls.py +++ b/tests/admin_docs/urls.py @@ -1,18 +1,18 @@ -from django.conf.urls import include, url from django.contrib import admin +from django.urls import include, path from . import views ns_patterns = ([ - url(r'^xview/func/$', views.xview_dec(views.xview), name='func'), + path('xview/func/', views.xview_dec(views.xview), name='func'), ], 'test') urlpatterns = [ - url(r'^admin/', admin.site.urls), - url(r'^admindocs/', include('django.contrib.admindocs.urls')), - url(r'^', include(ns_patterns, namespace='test')), - url(r'^xview/func/$', views.xview_dec(views.xview)), - url(r'^xview/class/$', views.xview_dec(views.XViewClass.as_view())), - url(r'^xview/callable_object/$', views.xview_dec(views.XViewCallableObject())), - url(r'^xview/callable_object_without_xview/$', views.XViewCallableObject()), + path('admin/', admin.site.urls), + path('admindocs/', include('django.contrib.admindocs.urls')), + path('', include(ns_patterns, namespace='test')), + path('xview/func/', views.xview_dec(views.xview)), + path('xview/class/', views.xview_dec(views.XViewClass.as_view())), + path('xview/callable_object/', views.xview_dec(views.XViewCallableObject())), + path('xview/callable_object_without_xview/', views.XViewCallableObject()), ] diff --git a/tests/admin_inlines/urls.py b/tests/admin_inlines/urls.py index 1f553a85a9..be569cdca5 100644 --- a/tests/admin_inlines/urls.py +++ b/tests/admin_inlines/urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import url +from django.urls import path from . import admin urlpatterns = [ - url(r'^admin/', admin.site.urls), + path('admin/', admin.site.urls), ] diff --git a/tests/admin_scripts/urls.py b/tests/admin_scripts/urls.py index edb5e1f3b0..b5bb443926 100644 --- a/tests/admin_scripts/urls.py +++ b/tests/admin_scripts/urls.py @@ -1,11 +1,11 @@ import os -from django.conf.urls import url +from django.urls import path from django.views.static import serve here = os.path.dirname(__file__) urlpatterns = [ - url(r'^custom_templates/(?P.*)$', serve, { - 'document_root': os.path.join(here, 'custom_templates')}), + path('custom_templates/', serve, { + 'document_root': os.path.join(here, 'custom_templates')}), ] diff --git a/tests/admin_utils/urls.py b/tests/admin_utils/urls.py index b3b865f8bc..2e472fc575 100644 --- a/tests/admin_utils/urls.py +++ b/tests/admin_utils/urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import url +from django.urls import path from .admin import site urlpatterns = [ - url(r'^test_admin/admin/', site.urls), + path('test_admin/admin/', site.urls), ] diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index 5dc2a5811b..5c4151c270 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -5,7 +5,6 @@ from io import StringIO from wsgiref.util import FileWrapper from django import forms -from django.conf.urls import url from django.contrib import admin from django.contrib.admin import BooleanFieldListFilter from django.contrib.admin.views.main import ChangeList @@ -17,6 +16,7 @@ from django.core.mail import EmailMessage from django.db import models from django.forms.models import BaseModelFormSet from django.http import HttpResponse, StreamingHttpResponse +from django.urls import path from django.utils.html import format_html from django.utils.safestring import mark_safe @@ -704,7 +704,7 @@ class ReportAdmin(admin.ModelAdmin): def get_urls(self): # Corner case: Don't call parent implementation - return [url(r'^extra/$', self.extra, name='cable_extra')] + return [path('extra/', self.extra, name='cable_extra')] class CustomTemplateBooleanFieldListFilter(BooleanFieldListFilter): diff --git a/tests/admin_views/customadmin.py b/tests/admin_views/customadmin.py index 9331918b37..a9d8a060b9 100644 --- a/tests/admin_views/customadmin.py +++ b/tests/admin_views/customadmin.py @@ -1,11 +1,11 @@ """ A second, custom AdminSite -- see tests.CustomAdminSiteTests. """ -from django.conf.urls import url from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User from django.http import HttpResponse +from django.urls import path from . import admin as base_admin, forms, models @@ -25,7 +25,7 @@ class Admin2(admin.AdminSite): def get_urls(self): return [ - url(r'^my_view/$', self.admin_view(self.my_view), name='my_view'), + path('my_view/', self.admin_view(self.my_view), name='my_view'), ] + super().get_urls() def my_view(self, request): diff --git a/tests/admin_views/test_adminsite.py b/tests/admin_views/test_adminsite.py index 86e0a357db..efee6f39c6 100644 --- a/tests/admin_views/test_adminsite.py +++ b/tests/admin_views/test_adminsite.py @@ -1,10 +1,9 @@ -from django.conf.urls import url from django.contrib import admin from django.contrib.admin.actions import delete_selected from django.contrib.auth.models import User from django.test import SimpleTestCase, TestCase, override_settings from django.test.client import RequestFactory -from django.urls import reverse +from django.urls import path, reverse from .models import Article @@ -13,7 +12,7 @@ site.register(User) site.register(Article) urlpatterns = [ - url(r'^test_admin/admin/', site.urls), + path('test_admin/admin/', site.urls), ] diff --git a/tests/admin_views/test_multidb.py b/tests/admin_views/test_multidb.py index 9907e16d69..ec3591d1fe 100644 --- a/tests/admin_views/test_multidb.py +++ b/tests/admin_views/test_multidb.py @@ -1,11 +1,10 @@ from unittest import mock -from django.conf.urls import url from django.contrib import admin from django.contrib.auth.models import User from django.db import connections from django.test import TestCase, override_settings -from django.urls import reverse +from django.urls import path, reverse from .models import Book @@ -23,7 +22,7 @@ site = admin.AdminSite(name='test_adminsite') site.register(Book) urlpatterns = [ - url(r'^admin/', site.urls), + path('admin/', site.urls), ] diff --git a/tests/admin_views/urls.py b/tests/admin_views/urls.py index 545df313e4..fdb61d759d 100644 --- a/tests/admin_views/urls.py +++ b/tests/admin_views/urls.py @@ -1,23 +1,23 @@ -from django.conf.urls import include, url +from django.urls import include, path from . import admin, custom_has_permission_admin, customadmin, views from .test_autocomplete_view import site as autocomplete_site urlpatterns = [ - url(r'^test_admin/admin/doc/', include('django.contrib.admindocs.urls')), - url(r'^test_admin/admin/secure-view/$', views.secure_view, name='secure_view'), - url(r'^test_admin/admin/secure-view2/$', views.secure_view2, name='secure_view2'), - url(r'^test_admin/admin/', admin.site.urls), - url(r'^test_admin/admin2/', customadmin.site.urls), - url(r'^test_admin/admin3/', (admin.site.get_urls(), 'admin', 'admin3'), {'form_url': 'pony'}), - url(r'^test_admin/admin4/', customadmin.simple_site.urls), - url(r'^test_admin/admin5/', admin.site2.urls), - url(r'^test_admin/admin6/', admin.site6.urls), - url(r'^test_admin/admin7/', admin.site7.urls), + path('test_admin/admin/doc/', include('django.contrib.admindocs.urls')), + path('test_admin/admin/secure-view/', views.secure_view, name='secure_view'), + path('test_admin/admin/secure-view2/', views.secure_view2, name='secure_view2'), + path('test_admin/admin/', admin.site.urls), + path('test_admin/admin2/', customadmin.site.urls), + path('test_admin/admin3/', (admin.site.get_urls(), 'admin', 'admin3'), {'form_url': 'pony'}), + path('test_admin/admin4/', customadmin.simple_site.urls), + path('test_admin/admin5/', admin.site2.urls), + path('test_admin/admin6/', admin.site6.urls), + path('test_admin/admin7/', admin.site7.urls), # All admin views accept `extra_context` to allow adding it like this: - url(r'^test_admin/admin8/', (admin.site.get_urls(), 'admin', 'admin-extra-context'), {'extra_context': {}}), - url(r'^test_admin/admin9/', admin.site9.urls), - url(r'^test_admin/admin10/', admin.site10.urls), - url(r'^test_admin/has_permission_admin/', custom_has_permission_admin.site.urls), - url(r'^test_admin/autocomplete_admin/', autocomplete_site.urls), + path('test_admin/admin8/', (admin.site.get_urls(), 'admin', 'admin-extra-context'), {'extra_context': {}}), + path('test_admin/admin9/', admin.site9.urls), + path('test_admin/admin10/', admin.site10.urls), + path('test_admin/has_permission_admin/', custom_has_permission_admin.site.urls), + path('test_admin/autocomplete_admin/', autocomplete_site.urls), ] diff --git a/tests/admin_widgets/urls.py b/tests/admin_widgets/urls.py index 3381b2f13a..d9372ac756 100644 --- a/tests/admin_widgets/urls.py +++ b/tests/admin_widgets/urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import url +from django.urls import path from . import widgetadmin urlpatterns = [ - url(r'^', widgetadmin.site.urls), + path('', widgetadmin.site.urls), ] diff --git a/tests/auth_tests/test_admin_multidb.py b/tests/auth_tests/test_admin_multidb.py index f86ea86dd8..eff458de19 100644 --- a/tests/auth_tests/test_admin_multidb.py +++ b/tests/auth_tests/test_admin_multidb.py @@ -1,12 +1,11 @@ from unittest import mock -from django.conf.urls import url from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User from django.db import connections from django.test import TestCase, override_settings -from django.urls import reverse +from django.urls import path, reverse class Router: @@ -22,7 +21,7 @@ site = admin.AdminSite(name='test_adminsite') site.register(User, admin_class=UserAdmin) urlpatterns = [ - url(r'^admin/', site.urls), + path('admin/', site.urls), ] diff --git a/tests/auth_tests/test_views.py b/tests/auth_tests/test_views.py index d4311a0fad..4949ce1bf4 100644 --- a/tests/auth_tests/test_views.py +++ b/tests/auth_tests/test_views.py @@ -319,7 +319,7 @@ class PasswordResetTest(AuthViewsTestCase): ] ) def test_confirm_login_post_reset_custom_backend(self): - # This backend is specified in the url(). + # This backend is specified in the URL pattern. backend = 'django.contrib.auth.backends.AllowAllUsersModelBackend' url, path = self._test_confirm_start() path = path.replace('/reset/', '/reset/post_reset_login_custom_backend/') diff --git a/tests/auth_tests/urls.py b/tests/auth_tests/urls.py index 9dc23cee88..d0b259935b 100644 --- a/tests/auth_tests/urls.py +++ b/tests/auth_tests/urls.py @@ -1,4 +1,3 @@ -from django.conf.urls import url from django.contrib import admin from django.contrib.auth import views from django.contrib.auth.decorators import login_required, permission_required @@ -8,7 +7,7 @@ from django.contrib.messages.api import info from django.http import HttpRequest, HttpResponse from django.shortcuts import render from django.template import RequestContext, Template -from django.urls import path, reverse_lazy +from django.urls import path, re_path, reverse_lazy from django.views.decorators.cache import never_cache @@ -82,63 +81,73 @@ uid_token = r'(?P[0-9A-Za-z_\-]+)/(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z # special urls for auth test cases urlpatterns = auth_urlpatterns + [ - url(r'^logout/custom_query/$', views.LogoutView.as_view(redirect_field_name='follow')), - url(r'^logout/next_page/$', views.LogoutView.as_view(next_page='/somewhere/')), - url(r'^logout/next_page/named/$', views.LogoutView.as_view(next_page='password_reset')), - url(r'^logout/allowed_hosts/$', views.LogoutView.as_view(success_url_allowed_hosts={'otherserver'})), - url(r'^remote_user/$', remote_user_auth_view), + path('logout/custom_query/', views.LogoutView.as_view(redirect_field_name='follow')), + path('logout/next_page/', views.LogoutView.as_view(next_page='/somewhere/')), + path('logout/next_page/named/', views.LogoutView.as_view(next_page='password_reset')), + path('logout/allowed_hosts/', views.LogoutView.as_view(success_url_allowed_hosts={'otherserver'})), + path('remote_user/', remote_user_auth_view), - url(r'^password_reset_from_email/$', - views.PasswordResetView.as_view(from_email='staffmember@example.com')), - url(r'^password_reset_extra_email_context/$', + path('password_reset_from_email/', views.PasswordResetView.as_view(from_email='staffmember@example.com')), + path( + 'password_reset_extra_email_context/', views.PasswordResetView.as_view(extra_email_context={'greeting': 'Hello!'})), - url(r'^password_reset/custom_redirect/$', + path( + 'password_reset/custom_redirect/', views.PasswordResetView.as_view(success_url='/custom/')), - url(r'^password_reset/custom_redirect/named/$', + path( + 'password_reset/custom_redirect/named/', views.PasswordResetView.as_view(success_url=reverse_lazy('password_reset'))), - url(r'^password_reset/html_email_template/$', + path( + 'password_reset/html_email_template/', views.PasswordResetView.as_view( html_email_template_name='registration/html_password_reset_email.html' )), - url(r'^reset/custom/{}/$'.format(uid_token), - views.PasswordResetConfirmView.as_view(success_url='/custom/')), - url(r'^reset/custom/named/{}/$'.format(uid_token), - views.PasswordResetConfirmView.as_view(success_url=reverse_lazy('password_reset'))), - url(r'^reset/post_reset_login/{}/$'.format(uid_token), - views.PasswordResetConfirmView.as_view(post_reset_login=True)), - url( - r'^reset/post_reset_login_custom_backend/{}/$'.format(uid_token), + re_path( + '^reset/custom/{}/$'.format(uid_token), + views.PasswordResetConfirmView.as_view(success_url='/custom/'), + ), + re_path( + '^reset/custom/named/{}/$'.format(uid_token), + views.PasswordResetConfirmView.as_view(success_url=reverse_lazy('password_reset')), + ), + re_path( + '^reset/post_reset_login/{}/$'.format(uid_token), + views.PasswordResetConfirmView.as_view(post_reset_login=True), + ), + re_path( + '^reset/post_reset_login_custom_backend/{}/$'.format(uid_token), views.PasswordResetConfirmView.as_view( post_reset_login=True, post_reset_login_backend='django.contrib.auth.backends.AllowAllUsersModelBackend', ), ), - url(r'^password_change/custom/$', - views.PasswordChangeView.as_view(success_url='/custom/')), - url(r'^password_change/custom/named/$', - views.PasswordChangeView.as_view(success_url=reverse_lazy('password_reset'))), - url(r'^login_required/$', login_required(views.PasswordResetView.as_view())), - url(r'^login_required_login_url/$', login_required(views.PasswordResetView.as_view(), login_url='/somewhere/')), + path('password_change/custom/', + views.PasswordChangeView.as_view(success_url='/custom/')), + path('password_change/custom/named/', + views.PasswordChangeView.as_view(success_url=reverse_lazy('password_reset'))), + path('login_required/', login_required(views.PasswordResetView.as_view())), + path('login_required_login_url/', login_required(views.PasswordResetView.as_view(), login_url='/somewhere/')), - url(r'^auth_processor_no_attr_access/$', auth_processor_no_attr_access), - url(r'^auth_processor_attr_access/$', auth_processor_attr_access), - url(r'^auth_processor_user/$', auth_processor_user), - url(r'^auth_processor_perms/$', auth_processor_perms), - url(r'^auth_processor_perm_in_perms/$', auth_processor_perm_in_perms), - url(r'^auth_processor_messages/$', auth_processor_messages), - url(r'^custom_request_auth_login/$', + path('auth_processor_no_attr_access/', auth_processor_no_attr_access), + path('auth_processor_attr_access/', auth_processor_attr_access), + path('auth_processor_user/', auth_processor_user), + path('auth_processor_perms/', auth_processor_perms), + path('auth_processor_perm_in_perms/', auth_processor_perm_in_perms), + path('auth_processor_messages/', auth_processor_messages), + path( + 'custom_request_auth_login/', views.LoginView.as_view(authentication_form=CustomRequestAuthenticationForm)), - url(r'^userpage/(.+)/$', userpage, name="userpage"), - url(r'^login/redirect_authenticated_user_default/$', views.LoginView.as_view()), - url(r'^login/redirect_authenticated_user/$', - views.LoginView.as_view(redirect_authenticated_user=True)), - url(r'^login/allowed_hosts/$', - views.LoginView.as_view(success_url_allowed_hosts={'otherserver'})), + re_path('^userpage/(.+)/$', userpage, name='userpage'), + path('login/redirect_authenticated_user_default/', views.LoginView.as_view()), + path('login/redirect_authenticated_user/', + views.LoginView.as_view(redirect_authenticated_user=True)), + path('login/allowed_hosts/', + views.LoginView.as_view(success_url_allowed_hosts={'otherserver'})), path('permission_required_redirect/', permission_required_redirect), path('permission_required_exception/', permission_required_exception), path('login_and_permission_required_exception/', login_and_permission_required_exception), # This line is only required to render the password reset with is_admin=True - url(r'^admin/', admin.site.urls), + path('admin/', admin.site.urls), ] diff --git a/tests/auth_tests/urls_admin.py b/tests/auth_tests/urls_admin.py index 8e5b0f1f0c..21b0073210 100644 --- a/tests/auth_tests/urls_admin.py +++ b/tests/auth_tests/urls_admin.py @@ -2,11 +2,11 @@ Test URLs for auth admins. """ -from django.conf.urls import url from django.contrib import admin from django.contrib.auth.admin import GroupAdmin, UserAdmin from django.contrib.auth.models import Group, User from django.contrib.auth.urls import urlpatterns +from django.urls import path # Create a silo'd admin site for just the user/group admins. site = admin.AdminSite(name='auth_test_admin') @@ -14,5 +14,5 @@ site.register(User, UserAdmin) site.register(Group, GroupAdmin) urlpatterns += [ - url(r'^admin/', site.urls), + path('admin/', site.urls), ] diff --git a/tests/auth_tests/urls_custom_user_admin.py b/tests/auth_tests/urls_custom_user_admin.py index 59b80d04d7..83d93d5cfe 100644 --- a/tests/auth_tests/urls_custom_user_admin.py +++ b/tests/auth_tests/urls_custom_user_admin.py @@ -1,7 +1,7 @@ -from django.conf.urls import url from django.contrib import admin from django.contrib.auth import get_user_model from django.contrib.auth.admin import UserAdmin +from django.urls import path site = admin.AdminSite(name='custom_user_admin') @@ -19,5 +19,5 @@ class CustomUserAdmin(UserAdmin): site.register(get_user_model(), CustomUserAdmin) urlpatterns = [ - url(r'^admin/', site.urls), + path('admin/', site.urls), ] diff --git a/tests/check_framework/test_urls.py b/tests/check_framework/test_urls.py index cdc9595731..67de26c690 100644 --- a/tests/check_framework/test_urls.py +++ b/tests/check_framework/test_urls.py @@ -20,7 +20,7 @@ class CheckUrlConfigTests(SimpleTestCase): @override_settings(ROOT_URLCONF='check_framework.urls.warning_in_include') def test_check_resolver_recursive(self): - # The resolver is checked recursively (examining url()s in include()). + # The resolver is checked recursively (examining URL patterns in include()). result = check_url_config(None) self.assertEqual(len(result), 1) warning = result[0] diff --git a/tests/check_framework/urls/beginning_with_slash.py b/tests/check_framework/urls/beginning_with_slash.py index 8dac96745c..bd4e29d8f1 100644 --- a/tests/check_framework/urls/beginning_with_slash.py +++ b/tests/check_framework/urls/beginning_with_slash.py @@ -1,7 +1,6 @@ -from django.conf.urls import url -from django.urls import path +from django.urls import path, re_path urlpatterns = [ path('/path-starting-with-slash/', lambda x: x), - url(r'/url-starting-with-slash/$', lambda x: x), + re_path(r'/url-starting-with-slash/$', lambda x: x), ] diff --git a/tests/check_framework/urls/include_with_dollar.py b/tests/check_framework/urls/include_with_dollar.py index 3d4a55b41f..ce921bbec5 100644 --- a/tests/check_framework/urls/include_with_dollar.py +++ b/tests/check_framework/urls/include_with_dollar.py @@ -1,5 +1,5 @@ -from django.conf.urls import include, url +from django.urls import include, re_path urlpatterns = [ - url(r'^include-with-dollar$', include([])), + re_path('^include-with-dollar$', include([])), ] diff --git a/tests/check_framework/urls/name_with_colon.py b/tests/check_framework/urls/name_with_colon.py index f7bc0c18b4..273c99324c 100644 --- a/tests/check_framework/urls/name_with_colon.py +++ b/tests/check_framework/urls/name_with_colon.py @@ -1,5 +1,5 @@ -from django.conf.urls import url +from django.urls import re_path urlpatterns = [ - url(r'^$', lambda x: x, name='name_with:colon'), + re_path('^$', lambda x: x, name='name_with:colon'), ] diff --git a/tests/check_framework/urls/no_warnings.py b/tests/check_framework/urls/no_warnings.py index 773ad27ef1..e1846fb884 100644 --- a/tests/check_framework/urls/no_warnings.py +++ b/tests/check_framework/urls/no_warnings.py @@ -1,9 +1,9 @@ -from django.conf.urls import include, url +from django.urls import include, path, re_path urlpatterns = [ - url(r'^foo/', lambda x: x, name='foo'), + path('foo/', lambda x: x, name='foo'), # This dollar is ok as it is escaped - url(r'^\$', include([ - url(r'^bar/$', lambda x: x, name='bar'), + re_path(r'^\$', include([ + path('bar/', lambda x: x, name='bar'), ])), ] diff --git a/tests/check_framework/urls/no_warnings_i18n.py b/tests/check_framework/urls/no_warnings_i18n.py index 7c494c7dc9..37da78f29d 100644 --- a/tests/check_framework/urls/no_warnings_i18n.py +++ b/tests/check_framework/urls/no_warnings_i18n.py @@ -1,7 +1,7 @@ -from django.conf.urls import url from django.conf.urls.i18n import i18n_patterns +from django.urls import path from django.utils.translation import gettext_lazy as _ urlpatterns = i18n_patterns( - url(_('translated/'), lambda x: x, name='i18n_prefixed'), + path(_('translated/'), lambda x: x, name='i18n_prefixed'), ) diff --git a/tests/check_framework/urls/non_unique_namespaces.py b/tests/check_framework/urls/non_unique_namespaces.py index 781be4c6d0..f036797cb7 100644 --- a/tests/check_framework/urls/non_unique_namespaces.py +++ b/tests/check_framework/urls/non_unique_namespaces.py @@ -1,13 +1,13 @@ -from django.conf.urls import include, url +from django.urls import include, path common_url_patterns = ([ - url(r'^app-ns1/', include([])), - url(r'^app-url/', include([])), + path('app-ns1/', include([])), + path('app-url/', include([])), ], 'app-ns1') urlpatterns = [ - url(r'^app-ns1-0/', include(common_url_patterns)), - url(r'^app-ns1-1/', include(common_url_patterns)), - url(r'^app-some-url/', include(([], 'app'), namespace='app-1')), - url(r'^app-some-url-2/', include(([], 'app'), namespace='app-1')) + path('app-ns1-0/', include(common_url_patterns)), + path('app-ns1-1/', include(common_url_patterns)), + path('app-some-url/', include(([], 'app'), namespace='app-1')), + path('app-some-url-2/', include(([], 'app'), namespace='app-1')) ] diff --git a/tests/check_framework/urls/unique_namespaces.py b/tests/check_framework/urls/unique_namespaces.py index b3f7fd70d0..09296648fd 100644 --- a/tests/check_framework/urls/unique_namespaces.py +++ b/tests/check_framework/urls/unique_namespaces.py @@ -1,20 +1,20 @@ -from django.conf.urls import include, url +from django.urls import include, path common_url_patterns = ([ - url(r'^app-ns1/', include([])), - url(r'^app-url/', include([])), + path('app-ns1/', include([])), + path('app-url/', include([])), ], 'common') nested_url_patterns = ([ - url(r'^common/', include(common_url_patterns, namespace='nested')), + path('common/', include(common_url_patterns, namespace='nested')), ], 'nested') urlpatterns = [ - url(r'^app-ns1-0/', include(common_url_patterns, namespace='app-include-1')), - url(r'^app-ns1-1/', include(common_url_patterns, namespace='app-include-2')), + path('app-ns1-0/', include(common_url_patterns, namespace='app-include-1')), + path('app-ns1-1/', include(common_url_patterns, namespace='app-include-2')), # 'nested' is included twice but namespaced by nested-1 and nested-2. - url(r'^app-ns1-2/', include(nested_url_patterns, namespace='nested-1')), - url(r'^app-ns1-3/', include(nested_url_patterns, namespace='nested-2')), + path('app-ns1-2/', include(nested_url_patterns, namespace='nested-1')), + path('app-ns1-3/', include(nested_url_patterns, namespace='nested-2')), # namespaced URLs inside non-namespaced URLs. - url(r'^app-ns1-4/', include([url(r'^abc/', include(common_url_patterns))])), + path('app-ns1-4/', include([path('abc/', include(common_url_patterns))])), ] diff --git a/tests/check_framework/urls/warning_in_include.py b/tests/check_framework/urls/warning_in_include.py index 5bb94c9688..8ec846be1e 100644 --- a/tests/check_framework/urls/warning_in_include.py +++ b/tests/check_framework/urls/warning_in_include.py @@ -1,7 +1,7 @@ -from django.conf.urls import include, url +from django.urls import include, path, re_path urlpatterns = [ - url(r'^', include([ - url(r'^include-with-dollar$', include([])), + path('', include([ + re_path('^include-with-dollar$', include([])), ])), ] diff --git a/tests/conditional_processing/urls.py b/tests/conditional_processing/urls.py index 4b092a5ae1..48133d2f36 100644 --- a/tests/conditional_processing/urls.py +++ b/tests/conditional_processing/urls.py @@ -1,14 +1,14 @@ -from django.conf.urls import url +from django.urls import path from . import views urlpatterns = [ - url('^condition/$', views.index), - url('^condition/last_modified/$', views.last_modified_view1), - url('^condition/last_modified2/$', views.last_modified_view2), - url('^condition/etag/$', views.etag_view1), - url('^condition/etag2/$', views.etag_view2), - url('^condition/unquoted_etag/$', views.etag_view_unquoted), - url('^condition/weak_etag/$', views.etag_view_weak), - url('^condition/no_etag/$', views.etag_view_none), + path('condition/', views.index), + path('condition/last_modified/', views.last_modified_view1), + path('condition/last_modified2/', views.last_modified_view2), + path('condition/etag/', views.etag_view1), + path('condition/etag2/', views.etag_view2), + path('condition/unquoted_etag/', views.etag_view_unquoted), + path('condition/weak_etag/', views.etag_view_weak), + path('condition/no_etag/', views.etag_view_none), ] diff --git a/tests/contenttypes_tests/urls.py b/tests/contenttypes_tests/urls.py index 779e8c4a60..1403b00ac4 100644 --- a/tests/contenttypes_tests/urls.py +++ b/tests/contenttypes_tests/urls.py @@ -1,6 +1,6 @@ -from django.conf.urls import url from django.contrib.contenttypes import views +from django.urls import re_path urlpatterns = [ - url(r'^shortcut/([0-9]+)/(.*)/$', views.shortcut), + re_path(r'^shortcut/([0-9]+)/(.*)/$', views.shortcut), ] diff --git a/tests/context_processors/urls.py b/tests/context_processors/urls.py index ac887f6613..b8297086a7 100644 --- a/tests/context_processors/urls.py +++ b/tests/context_processors/urls.py @@ -1,8 +1,8 @@ -from django.conf.urls import url +from django.urls import path from . import views urlpatterns = [ - url(r'^request_attrs/$', views.request_processor), - url(r'^debug/$', views.debug_processor), + path('request_attrs/', views.request_processor), + path('debug/', views.debug_processor), ] diff --git a/tests/file_storage/urls.py b/tests/file_storage/urls.py index 2bf659f6a8..24c5dcbc56 100644 --- a/tests/file_storage/urls.py +++ b/tests/file_storage/urls.py @@ -1,6 +1,6 @@ -from django.conf.urls import url from django.http import HttpResponse +from django.urls import path urlpatterns = [ - url(r'^$', lambda req: HttpResponse('example view')), + path('', lambda req: HttpResponse('example view')), ] diff --git a/tests/file_uploads/urls.py b/tests/file_uploads/urls.py index 504554483e..3e7985d2f9 100644 --- a/tests/file_uploads/urls.py +++ b/tests/file_uploads/urls.py @@ -1,18 +1,18 @@ -from django.conf.urls import url +from django.urls import path, re_path from . import views urlpatterns = [ - url(r'^upload/$', views.file_upload_view), - url(r'^verify/$', views.file_upload_view_verify), - url(r'^unicode_name/$', views.file_upload_unicode_name), - url(r'^echo/$', views.file_upload_echo), - url(r'^echo_content_type_extra/$', views.file_upload_content_type_extra), - url(r'^echo_content/$', views.file_upload_echo_content), - url(r'^quota/$', views.file_upload_quota), - url(r'^quota/broken/$', views.file_upload_quota_broken), - url(r'^getlist_count/$', views.file_upload_getlist_count), - url(r'^upload_errors/$', views.file_upload_errors), - url(r'^filename_case/$', views.file_upload_filename_case_view), - url(r'^fd_closing/(?Pt|f)/$', views.file_upload_fd_closing), + path('upload/', views.file_upload_view), + path('verify/', views.file_upload_view_verify), + path('unicode_name/', views.file_upload_unicode_name), + path('echo/', views.file_upload_echo), + path('echo_content_type_extra/', views.file_upload_content_type_extra), + path('echo_content/', views.file_upload_echo_content), + path('quota/', views.file_upload_quota), + path('quota/broken/', views.file_upload_quota_broken), + path('getlist_count/', views.file_upload_getlist_count), + path('upload_errors/', views.file_upload_errors), + path('filename_case/', views.file_upload_filename_case_view), + re_path(r'^fd_closing/(?Pt|f)/$', views.file_upload_fd_closing), ] diff --git a/tests/flatpages_tests/urls.py b/tests/flatpages_tests/urls.py index 5b2c576b14..3b6806d2b2 100644 --- a/tests/flatpages_tests/urls.py +++ b/tests/flatpages_tests/urls.py @@ -1,13 +1,13 @@ -from django.conf.urls import include, url from django.contrib.flatpages.sitemaps import FlatPageSitemap from django.contrib.sitemaps import views +from django.urls import include, path -# special urls for flatpage test cases urlpatterns = [ - url(r'^flatpages/sitemap\.xml$', views.sitemap, + path( + 'flatpages/sitemap.xml', views.sitemap, {'sitemaps': {'flatpages': FlatPageSitemap}}, name='django.contrib.sitemaps.views.sitemap'), - url(r'^flatpage_root', include('django.contrib.flatpages.urls')), - url(r'^accounts/', include('django.contrib.auth.urls')), + path('flatpage_root', include('django.contrib.flatpages.urls')), + path('accounts/', include('django.contrib.auth.urls')), ] diff --git a/tests/forms_tests/urls.py b/tests/forms_tests/urls.py index ab7fa902a9..dda75b52b4 100644 --- a/tests/forms_tests/urls.py +++ b/tests/forms_tests/urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import url +from django.urls import path from .views import ArticleFormView urlpatterns = [ - url(r'^model_form/(?P[0-9]+)/$', ArticleFormView.as_view(), name="article_form"), + path('model_form//', ArticleFormView.as_view(), name='article_form'), ] diff --git a/tests/generic_inline_admin/urls.py b/tests/generic_inline_admin/urls.py index 59f09437db..8800a0cb92 100644 --- a/tests/generic_inline_admin/urls.py +++ b/tests/generic_inline_admin/urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import url +from django.urls import path from . import admin urlpatterns = [ - url(r'^generic_inline_admin/admin/', admin.site.urls), + path('generic_inline_admin/admin/', admin.site.urls), ] diff --git a/tests/gis_tests/geoadmin/urls.py b/tests/gis_tests/geoadmin/urls.py index eb91d283d4..c27b1d7cda 100644 --- a/tests/gis_tests/geoadmin/urls.py +++ b/tests/gis_tests/geoadmin/urls.py @@ -1,6 +1,6 @@ -from django.conf.urls import include, url from django.contrib import admin +from django.urls import include, path urlpatterns = [ - url(r'^admin/', include(admin.site.urls)), + path('admin/', include(admin.site.urls)), ] diff --git a/tests/gis_tests/geoapp/urls.py b/tests/gis_tests/geoapp/urls.py index 0e148bf4f3..9635d8ddbf 100644 --- a/tests/gis_tests/geoapp/urls.py +++ b/tests/gis_tests/geoapp/urls.py @@ -1,24 +1,26 @@ -from django.conf.urls import url from django.contrib.gis import views as gis_views from django.contrib.gis.sitemaps import views as gis_sitemap_views from django.contrib.sitemaps import views as sitemap_views +from django.urls import path from .feeds import feed_dict from .sitemaps import sitemaps urlpatterns = [ - url(r'^feeds/(?P.*)/$', gis_views.feed, {'feed_dict': feed_dict}), + path('feeds//', gis_views.feed, {'feed_dict': feed_dict}), ] urlpatterns += [ - url(r'^sitemaps/(?P
\w+)\.xml$', sitemap_views.sitemap, {'sitemaps': sitemaps}), + path('sitemaps/
.xml', sitemap_views.sitemap, {'sitemaps': sitemaps}), ] urlpatterns += [ - url(r'^sitemaps/kml/(?P