diff options
author | Nicolas Delaby <nicolas@noa.one> | 2017-11-23 17:18:03 +0100 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2017-11-28 18:55:23 -0500 |
commit | 746caf3ef821dbf7588797cb2600fa81b9df9d1d (patch) | |
tree | 1007535c32eb1cdd044a4d0a31118e70dec75dd4 /tests/test_client | |
parent | 7a6fbf36b1fdb8978ea0842075ccce83bcd63789 (diff) | |
download | django-746caf3ef821dbf7588797cb2600fa81b9df9d1d.tar.gz |
Fixed #28837 -- Fixed test client crash if an exception with more than one arg is raised.
Also removed usage of the problematic pattern elsewhere.
Regression in 6e55e1d88a5c4453e25f0caf7ffb68973de5c0ba.
Diffstat (limited to 'tests/test_client')
-rw-r--r-- | tests/test_client/tests.py | 7 | ||||
-rw-r--r-- | tests/test_client/urls.py | 1 | ||||
-rw-r--r-- | tests/test_client/views.py | 9 |
3 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py index 5981ca319e..f7d32aa9cd 100644 --- a/tests/test_client/tests.py +++ b/tests/test_client/tests.py @@ -29,7 +29,7 @@ from django.test import ( ) from django.urls import reverse_lazy -from .views import get_view, post_view, trace_view +from .views import TwoArgException, get_view, post_view, trace_view @override_settings(ROOT_URLCONF='test_client.urls') @@ -713,6 +713,11 @@ class ClientTest(TestCase): with self.assertRaisesMessage(Exception, 'exception message'): self.client.get('/nesting_exception_view/') + def test_response_raises_multi_arg_exception(self): + """A request may raise an exception with more than one required arg.""" + with self.assertRaises(TwoArgException): + self.client.get('/two_arg_exception/') + def test_uploading_temp_file(self): with tempfile.TemporaryFile() as test_file: response = self.client.post('/upload_view/', data={'temp_file': test_file}) diff --git a/tests/test_client/urls.py b/tests/test_client/urls.py index 9f8d09218e..40ca384751 100644 --- a/tests/test_client/urls.py +++ b/tests/test_client/urls.py @@ -34,6 +34,7 @@ urlpatterns = [ url(r'^mass_mail_sending_view/$', views.mass_mail_sending_view), url(r'^nesting_exception_view/$', views.nesting_exception_view), url(r'^django_project_redirect/$', views.django_project_redirect), + url(r'^two_arg_exception/$', views.two_arg_exception), url(r'^accounts/$', RedirectView.as_view(url='login/')), url(r'^accounts/no_trailing_slash$', RedirectView.as_view(url='login/')), diff --git a/tests/test_client/views.py b/tests/test_client/views.py index 41a5f8518b..3387008d66 100644 --- a/tests/test_client/views.py +++ b/tests/test_client/views.py @@ -331,3 +331,12 @@ def django_project_redirect(request): def upload_view(request): """Prints keys of request.FILES to the response.""" return HttpResponse(', '.join(request.FILES)) + + +class TwoArgException(Exception): + def __init__(self, one, two): + pass + + +def two_arg_exception(request): + raise TwoArgException('one', 'two') |