1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #33351 -- Made path()/re_path() raise TypeError when kwargs argument is not a dict.

This commit is contained in:
mendespedro
2021-12-10 19:23:54 -03:00
committed by Mariusz Felisiak
parent 7e4a9a9f69
commit 75485d16a2
2 changed files with 14 additions and 1 deletions

View File

@@ -4,7 +4,9 @@ import uuid
from django.core.exceptions import ImproperlyConfigured
from django.test import SimpleTestCase
from django.test.utils import override_settings
from django.urls import NoReverseMatch, Resolver404, path, resolve, reverse
from django.urls import (
NoReverseMatch, Resolver404, path, re_path, resolve, reverse,
)
from django.views import View
from .converters import DynamicConverter
@@ -137,6 +139,13 @@ class SimplifiedURLTests(SimpleTestCase):
url = reverse('inner-extra', kwargs={'extra': 'something'})
self.assertEqual(url, '/included_urls/extra/something/')
def test_invalid_kwargs(self):
msg = 'kwargs argument must be a dict, but got str.'
with self.assertRaisesMessage(TypeError, msg):
path('hello/', empty_view, 'name')
with self.assertRaisesMessage(TypeError, msg):
re_path('^hello/$', empty_view, 'name')
def test_invalid_converter(self):
msg = "URL route 'foo/<nonexistent:var>/' uses invalid converter 'nonexistent'."
with self.assertRaisesMessage(ImproperlyConfigured, msg):