diff --git a/django/test/client.py b/django/test/client.py
index 87b59af..d22b122 100644
a
|
b
|
class Client(RequestFactory):
|
679 | 679 | 'Content-Type header is "{0}", not "application/json"' |
680 | 680 | .format(response.get('Content-Type')) |
681 | 681 | ) |
682 | | response._json = json.loads(response.content.decode(), **extra) |
| 682 | response._json = json.loads(response.content.decode('utf-8'), **extra) |
683 | 683 | return response._json |
684 | 684 | |
685 | 685 | def _handle_redirects(self, response, **extra): |
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py
index e110032..b3046d3 100644
a
|
b
|
class RequestMethodStringDataTests(SimpleTestCase):
|
1206 | 1206 | self.assertEqual(response['Content-Type'], content_type) |
1207 | 1207 | self.assertEqual(response.json(), {'key': 'value'}) |
1208 | 1208 | |
| 1209 | def test_unicode_json(self): |
| 1210 | response = self.client.get('/unicode_json_response/') |
| 1211 | self.assertEqual(response.json(), {'峠': 'とうげ tōge "mountain pass"'}) |
| 1212 | |
1209 | 1213 | def test_json_multiple_access(self): |
1210 | 1214 | response = self.client.get('/json_response/') |
1211 | 1215 | self.assertIs(response.json(), response.json()) |
diff --git a/tests/test_client_regress/urls.py b/tests/test_client_regress/urls.py
index 9821ea9..fcefeef 100644
a
|
b
|
urlpatterns = [
|
31 | 31 | url(r'^check_unicode/$', views.return_unicode), |
32 | 32 | url(r'^check_binary/$', views.return_undecodable_binary), |
33 | 33 | url(r'^json_response/$', views.return_json_response), |
| 34 | url(r'^unicode_json_response/$', views.return_unicode_json_response), |
34 | 35 | url(r'^parse_unicode_json/$', views.return_json_file), |
35 | 36 | url(r'^check_headers/$', views.check_headers), |
36 | 37 | url(r'^check_headers_redirect/$', RedirectView.as_view(url='/check_headers/')), |
diff --git a/tests/test_client_regress/views.py b/tests/test_client_regress/views.py
index 854cdc3..91b300a 100644
a
|
b
|
|
| 1 | # -*- coding:utf-8 -*- |
| 2 | |
1 | 3 | import json |
2 | 4 | from urllib.parse import urlencode |
3 | 5 | |
… |
… |
def return_json_response(request):
|
111 | 113 | return JsonResponse({'key': 'value'}, **kwargs) |
112 | 114 | |
113 | 115 | |
| 116 | def return_unicode_json_response(request): |
| 117 | content_type = request.GET.get('content_type') |
| 118 | kwargs = {'content_type': content_type} if content_type else {} |
| 119 | kwargs['json_dumps_params'] = {'ensure_ascii': False} |
| 120 | return JsonResponse({'峠': 'とうげ tōge "mountain pass"'}, **kwargs) |
| 121 | |
| 122 | |
114 | 123 | def return_json_file(request): |
115 | 124 | "A view that parses and returns a JSON string as a file." |
116 | 125 | match = CONTENT_TYPE_RE.match(request.META['CONTENT_TYPE']) |