1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Updated test URL patterns to use path() and re_path().

This commit is contained in:
Tim Graham
2018-12-07 17:52:28 -05:00
parent 1136d57f01
commit 043bd70942
104 changed files with 692 additions and 673 deletions

View File

@@ -7,7 +7,6 @@ import tempfile
from io import StringIO
from pathlib import Path
from django.conf.urls import url
from django.core import mail
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import DatabaseError, connection
@@ -15,7 +14,7 @@ from django.shortcuts import render
from django.template import TemplateDoesNotExist
from django.test import RequestFactory, SimpleTestCase, override_settings
from django.test.utils import LoggingCaptureMixin
from django.urls import reverse
from django.urls import path, reverse
from django.utils.functional import SimpleLazyObject
from django.utils.safestring import mark_safe
from django.utils.version import PY36
@@ -38,7 +37,7 @@ class User:
class WithoutEmptyPathUrls:
urlpatterns = [url(r'url/$', index_page, name='url')]
urlpatterns = [path('url/', index_page, name='url')]
class CallableSettingWrapperTests(SimpleTestCase):
@@ -105,9 +104,6 @@ class DebugViewTests(SimpleTestCase):
def test_404(self):
response = self.client.get('/raises404/')
self.assertEqual(response.status_code, 404)
def test_raised_404(self):
response = self.client.get('/views/raises404/')
self.assertContains(response, "<code>not-in-urls</code>, didn't match", status_code=404)
def test_404_not_in_urls(self):
@@ -128,12 +124,12 @@ class DebugViewTests(SimpleTestCase):
self.assertContains(response, "The empty path didn't match any of these.", status_code=404)
def test_technical_404(self):
response = self.client.get('/views/technical404/')
response = self.client.get('/technical404/')
self.assertContains(response, "Raised by:", status_code=404)
self.assertContains(response, "view_tests.views.technical404", status_code=404)
def test_classbased_technical_404(self):
response = self.client.get('/views/classbased404/')
response = self.client.get('/classbased404/')
self.assertContains(response, "Raised by:", status_code=404)
self.assertContains(response, "view_tests.views.Http404View", status_code=404)

View File

@@ -162,7 +162,7 @@ class SetLanguageTests(TestCase):
"""
The set_language view decodes the HTTP_REFERER URL.
"""
# The url() & view must exist for this to work as a regression test.
# The URL & view must exist for this to work as a regression test.
self.assertEqual(reverse('with_parameter', kwargs={'parameter': 'x'}), '/test-setlang/x/')
lang_code = self._get_inactive_language_code()
encoded_url = '/test-setlang/%C3%A4/' # (%C3%A4 decodes to ä)