summaryrefslogtreecommitdiff
path: root/tests/view_tests
diff options
context:
space:
mode:
authorTom Carrick <tom@carrick.eu>2020-07-14 13:32:24 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-09-14 08:41:59 +0200
commitbcc2befd0e9c1885e45b46d0b0bcdc11def8b249 (patch)
tree59fab69a3182286da87fcd6fe05a8ce0f4277a5a /tests/view_tests
parent71ae1ab0123582cc5bfe0f7d5f4cc19a9412f396 (diff)
Fixed #31789 -- Added a new headers interface to HttpResponse.
Diffstat (limited to 'tests/view_tests')
-rw-r--r--tests/view_tests/tests/test_debug.py2
-rw-r--r--tests/view_tests/tests/test_i18n.py2
-rw-r--r--tests/view_tests/tests/test_json.py2
-rw-r--r--tests/view_tests/tests/test_static.py8
4 files changed, 7 insertions, 7 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index 2337d3ed3d..80f5af89f7 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -1481,7 +1481,7 @@ class NonHTMLResponseExceptionReporterFilter(ExceptionReportTestMixin, LoggingCa
@override_settings(DEBUG=True, ROOT_URLCONF='view_tests.urls')
def test_non_html_response_encoding(self):
response = self.client.get('/raises500/', HTTP_ACCEPT='application/json')
- self.assertEqual(response['Content-Type'], 'text/plain; charset=utf-8')
+ self.assertEqual(response.headers['Content-Type'], 'text/plain; charset=utf-8')
class DecoratorsTests(SimpleTestCase):
diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py
index fcbffa711d..0ec2bf877e 100644
--- a/tests/view_tests/tests/test_i18n.py
+++ b/tests/view_tests/tests/test_i18n.py
@@ -249,7 +249,7 @@ class I18NViewTests(SimpleTestCase):
catalog = gettext.translation('djangojs', locale_dir, [lang_code])
trans_txt = catalog.gettext('this is to be translated')
response = self.client.get('/jsi18n/')
- self.assertEqual(response['Content-Type'], 'text/javascript; charset="utf-8"')
+ self.assertEqual(response.headers['Content-Type'], 'text/javascript; charset="utf-8"')
# response content must include a line like:
# "this is to be translated": <value of trans_txt Python variable>
# json.dumps() is used to be able to check Unicode strings.
diff --git a/tests/view_tests/tests/test_json.py b/tests/view_tests/tests/test_json.py
index 34e8fa359b..e1074bf630 100644
--- a/tests/view_tests/tests/test_json.py
+++ b/tests/view_tests/tests/test_json.py
@@ -10,7 +10,7 @@ class JsonResponseTests(SimpleTestCase):
response = self.client.get('/json/response/')
self.assertEqual(response.status_code, 200)
self.assertEqual(
- response['content-type'], 'application/json')
+ response.headers['content-type'], 'application/json')
self.assertEqual(json.loads(response.content.decode()), {
'a': [1, 2, 3],
'foo': {'bar': 'baz'},
diff --git a/tests/view_tests/tests/test_static.py b/tests/view_tests/tests/test_static.py
index f4c58e0611..5044aca2d6 100644
--- a/tests/view_tests/tests/test_static.py
+++ b/tests/view_tests/tests/test_static.py
@@ -29,7 +29,7 @@ class StaticTests(SimpleTestCase):
file_path = path.join(media_dir, filename)
with open(file_path, 'rb') as fp:
self.assertEqual(fp.read(), response_content)
- self.assertEqual(len(response_content), int(response['Content-Length']))
+ self.assertEqual(len(response_content), int(response.headers['Content-Length']))
self.assertEqual(mimetypes.guess_type(file_path)[1], response.get('Content-Encoding', None))
def test_chunked(self):
@@ -44,7 +44,7 @@ class StaticTests(SimpleTestCase):
def test_unknown_mime_type(self):
response = self.client.get('/%s/file.unknown' % self.prefix)
- self.assertEqual('application/octet-stream', response['Content-Type'])
+ self.assertEqual('application/octet-stream', response.headers['Content-Type'])
response.close()
def test_copes_with_empty_path_component(self):
@@ -87,7 +87,7 @@ class StaticTests(SimpleTestCase):
response_content = b''.join(response)
with open(path.join(media_dir, file_name), 'rb') as fp:
self.assertEqual(fp.read(), response_content)
- self.assertEqual(len(response_content), int(response['Content-Length']))
+ self.assertEqual(len(response_content), int(response.headers['Content-Length']))
def test_invalid_if_modified_since2(self):
"""Handle even more bogus If-Modified-Since values gracefully
@@ -102,7 +102,7 @@ class StaticTests(SimpleTestCase):
response_content = b''.join(response)
with open(path.join(media_dir, file_name), 'rb') as fp:
self.assertEqual(fp.read(), response_content)
- self.assertEqual(len(response_content), int(response['Content-Length']))
+ self.assertEqual(len(response_content), int(response.headers['Content-Length']))
def test_404(self):
response = self.client.get('/%s/nonexistent_resource' % self.prefix)