diff --git a/django/test/client.py b/django/test/client.py
index 2b5840b..7b4ab63 100644
a
|
b
|
class Client(RequestFactory):
|
683 | 683 | 'Content-Type header is "{0}", not "application/json"' |
684 | 684 | .format(response.get('Content-Type')) |
685 | 685 | ) |
686 | | return json.loads(response.content.decode(), **extra) |
| 686 | return json.loads(response.content.decode('utf-8'), **extra) |
687 | 687 | |
688 | 688 | def _handle_redirects(self, response, **extra): |
689 | 689 | "Follows any redirects by requesting responses from the server using GET." |
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py
index bb6d93b..2472fb3 100644
a
|
b
|
class RequestMethodStringDataTests(SimpleTestCase):
|
1204 | 1204 | response = self.client.get('/json_response/') |
1205 | 1205 | self.assertEqual(response.json(), {'key': 'value'}) |
1206 | 1206 | |
| 1207 | def test_unicode_json(self): |
| 1208 | response = self.client.get('/unicode_json_response/') |
| 1209 | self.assertEqual(response.json(), {'峠': 'とうげ tōge "mountain pass"'}) |
| 1210 | |
| 1211 | |
1207 | 1212 | def test_json_wrong_header(self): |
1208 | 1213 | response = self.client.get('/body/') |
1209 | 1214 | msg = 'Content-Type header is "text/html; charset=utf-8", not "application/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 abbf7e1..9195d7b 100644
a
|
b
|
|
| 1 | # -*- coding:utf-8 -*- |
| 2 | |
1 | 3 | import json |
2 | 4 | |
3 | 5 | from django.conf import settings |
… |
… |
def return_json_response(request):
|
111 | 113 | return JsonResponse({'key': 'value'}) |
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']) |