diff options
| author | Xavier Ordoquy | 2014-06-23 14:02:45 +0200 |
|---|---|---|
| committer | Xavier Ordoquy | 2014-06-23 14:02:45 +0200 |
| commit | 2489e38a06f575aa144644eee683bd87f20186ef (patch) | |
| tree | fc52fd2280d3ef6d0dc69d53a3771ee5f499ab29 /tests/test_views.py | |
| parent | 15c2c58b43a00ec29af99e0478b70eea57560fce (diff) | |
| parent | e11f41ebc4ef088a5849771dfda5a7fba4f82904 (diff) | |
| download | django-rest-framework-2489e38a06f575aa144644eee683bd87f20186ef.tar.bz2 | |
Merge remote-tracking branch 'origin/master' into 2.4.0
Conflicts:
.travis.yml
docs/api-guide/viewsets.md
rest_framework/serializers.py
rest_framework/throttling.py
tests/test_generics.py
tests/test_serializers.py
tox.ini
Diffstat (limited to 'tests/test_views.py')
| -rw-r--r-- | tests/test_views.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/test_views.py b/tests/test_views.py index 65c7e50e..77b113ee 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals +import sys import copy from django.test import TestCase from rest_framework import status @@ -11,6 +12,11 @@ from rest_framework.views import APIView factory = APIRequestFactory() +if sys.version_info[:2] >= (3, 4): + JSON_ERROR = 'JSON parse error - Expecting value:' +else: + JSON_ERROR = 'JSON parse error - No JSON object could be decoded' + class BasicView(APIView): def get(self, request, *args, **kwargs): @@ -48,7 +54,7 @@ def sanitise_json_error(error_dict): of json. """ ret = copy.copy(error_dict) - chop = len('JSON parse error - No JSON object could be decoded') + chop = len(JSON_ERROR) ret['detail'] = ret['detail'][:chop] return ret @@ -61,7 +67,7 @@ class ClassBasedViewIntegrationTests(TestCase): request = factory.post('/', 'f00bar', content_type='application/json') response = self.view(request) expected = { - 'detail': 'JSON parse error - No JSON object could be decoded' + 'detail': JSON_ERROR } self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(sanitise_json_error(response.data), expected) @@ -76,7 +82,7 @@ class ClassBasedViewIntegrationTests(TestCase): request = factory.post('/', form_data) response = self.view(request) expected = { - 'detail': 'JSON parse error - No JSON object could be decoded' + 'detail': JSON_ERROR } self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(sanitise_json_error(response.data), expected) @@ -90,7 +96,7 @@ class FunctionBasedViewIntegrationTests(TestCase): request = factory.post('/', 'f00bar', content_type='application/json') response = self.view(request) expected = { - 'detail': 'JSON parse error - No JSON object could be decoded' + 'detail': JSON_ERROR } self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(sanitise_json_error(response.data), expected) @@ -105,7 +111,7 @@ class FunctionBasedViewIntegrationTests(TestCase): request = factory.post('/', form_data) response = self.view(request) expected = { - 'detail': 'JSON parse error - No JSON object could be decoded' + 'detail': JSON_ERROR } self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(sanitise_json_error(response.data), expected) |
