diff options
| author | David Evans <d@evans.io> | 2016-04-26 18:43:34 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-04-29 10:55:01 -0400 |
| commit | 2fcafd169b5fcf4bb6711ca8aa4d59d80225ec7a (patch) | |
| tree | 7aab4f997b5e2b66bd3fb4f736e7a4bc2db1e29d /tests/handlers/tests.py | |
| parent | 9f8941eda4b98044d0bf0fea6bb3ba579d382109 (diff) | |
Fixed #26546 -- Allowed HTTPStatus enum values for HttpResponse.status.
Diffstat (limited to 'tests/handlers/tests.py')
| -rw-r--r-- | tests/handlers/tests.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py index a3f3ec7f70..d0b161cf44 100644 --- a/tests/handlers/tests.py +++ b/tests/handlers/tests.py @@ -2,6 +2,8 @@ from __future__ import unicode_literals +import unittest + from django.core.handlers.wsgi import WSGIHandler, WSGIRequest, get_script_name from django.core.signals import request_finished, request_started from django.db import close_old_connections, connection @@ -11,6 +13,11 @@ from django.test import ( from django.utils import six from django.utils.encoding import force_str +try: + from http import HTTPStatus +except ImportError: # Python < 3.5 + HTTPStatus = None + class HandlerTests(SimpleTestCase): @@ -160,16 +167,12 @@ class SignalsTests(SimpleTestCase): @override_settings(ROOT_URLCONF='handlers.urls') -class HandlerSuspiciousOpsTest(SimpleTestCase): +class HandlerRequestTests(SimpleTestCase): def test_suspiciousop_in_view_returns_400(self): response = self.client.get('/suspicious/') self.assertEqual(response.status_code, 400) - -@override_settings(ROOT_URLCONF='handlers.urls') -class HandlerNotFoundTest(SimpleTestCase): - def test_invalid_urls(self): response = self.client.get('~%A9helloworld') self.assertContains(response, '~%A9helloworld', status_code=404) @@ -187,6 +190,15 @@ class HandlerNotFoundTest(SimpleTestCase): environ = RequestFactory().get('/%E2%A8%87%87%A5%E2%A8%A0').environ self.assertIsInstance(environ['PATH_INFO'], six.text_type) + @unittest.skipIf(HTTPStatus is None, 'HTTPStatus only exists on Python 3.5+') + def test_handle_accepts_httpstatus_enum_value(self): + def start_response(status, headers): + start_response.status = status + + environ = RequestFactory().get('/httpstatus_enum/').environ + WSGIHandler()(environ, start_response) + self.assertEqual(start_response.status, '200 OK') + class ScriptNameTests(SimpleTestCase): def test_get_script_name(self): |
