Fixed #29553 -- Made test client set Content-Length header to a string rather than integer.

This commit is contained in:
Tim Graham 2018-07-09 11:44:49 -04:00 committed by GitHub
parent 857f860d56
commit 5bea8d256d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -401,7 +401,7 @@ class RequestFactory:
}
if data:
r.update({
'CONTENT_LENGTH': len(data),
'CONTENT_LENGTH': str(len(data)),
'CONTENT_TYPE': content_type,
'wsgi.input': FakePayload(data),
})

View File

@ -228,6 +228,9 @@ Miscellaneous
have existing invalid data and run a migration that recreates a table, you'll
see ``CHECK constraint failed``.
* For consistency with WSGI servers, the test client now sets the
``Content-Length`` header to a string rather than an integer.
.. _deprecated-features-2.2:
Features deprecated in 2.2

View File

@ -122,7 +122,7 @@ class ClientTest(TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.templates[0].name, 'PUT Template')
self.assertEqual(response.context['data'], "{'foo': 'bar'}")
self.assertEqual(response.context['Content-Length'], 14)
self.assertEqual(response.context['Content-Length'], '14')
def test_trace(self):
"""TRACE a view"""