mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-03-03 19:00:17 +03:00
Fixes #35 - Import json from django's built-in package (Does cleverness in determing best lib to use)
This commit is contained in:
parent
d0fe36aaa4
commit
3d15adaeb1
|
@ -3,10 +3,11 @@ django-rest-framework also provides HTML and PlainText emitters that help self-d
|
||||||
by serializing the output along with documentation regarding the Resource, output status and headers,
|
by serializing the output along with documentation regarding the Resource, output status and headers,
|
||||||
and providing forms and links depending on the allowed methods, emitters and parsers on the Resource.
|
and providing forms and links depending on the allowed methods, emitters and parsers on the Resource.
|
||||||
"""
|
"""
|
||||||
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.template import RequestContext, loader
|
from django.template import RequestContext, loader
|
||||||
from django import forms
|
from django.utils import simplejson as json
|
||||||
|
|
||||||
from djangorestframework.response import NoContent, ResponseException
|
from djangorestframework.response import NoContent, ResponseException
|
||||||
from djangorestframework.validators import FormValidatorMixin
|
from djangorestframework.validators import FormValidatorMixin
|
||||||
|
@ -21,11 +22,6 @@ import string
|
||||||
import re
|
import re
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
try:
|
|
||||||
import json
|
|
||||||
except ImportError:
|
|
||||||
import simplejson as json
|
|
||||||
|
|
||||||
|
|
||||||
_MSIE_USER_AGENT = re.compile(r'^Mozilla/[0-9]+\.[0-9]+ \([^)]*; MSIE [0-9]+\.[0-9]+[a-z]?;[^)]*\)(?!.* Opera )')
|
_MSIE_USER_AGENT = re.compile(r'^Mozilla/[0-9]+\.[0-9]+ \([^)]*; MSIE [0-9]+\.[0-9]+[a-z]?;[^)]*\)(?!.* Opera )')
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,13 @@ We need a method to be able to:
|
||||||
and multipart/form-data. (eg also handle multipart/json)
|
and multipart/form-data. (eg also handle multipart/json)
|
||||||
"""
|
"""
|
||||||
from django.http.multipartparser import MultiPartParser as DjangoMPParser
|
from django.http.multipartparser import MultiPartParser as DjangoMPParser
|
||||||
|
from django.utils import simplejson as json
|
||||||
|
|
||||||
from djangorestframework.response import ResponseException
|
from djangorestframework.response import ResponseException
|
||||||
from djangorestframework import status
|
from djangorestframework import status
|
||||||
from djangorestframework.utils import as_tuple
|
from djangorestframework.utils import as_tuple
|
||||||
from djangorestframework.mediatypes import MediaType
|
from djangorestframework.mediatypes import MediaType
|
||||||
|
|
||||||
try:
|
|
||||||
import json
|
|
||||||
except ImportError:
|
|
||||||
import simplejson as json
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from urlparse import parse_qs
|
from urlparse import parse_qs
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
from django.conf.urls.defaults import patterns
|
from django.conf.urls.defaults import patterns
|
||||||
from django.test import TestCase
|
from django.test import Client, TestCase
|
||||||
from django.test import Client
|
from django.utils import simplejson as json
|
||||||
|
|
||||||
from djangorestframework.compat import RequestFactory
|
from djangorestframework.compat import RequestFactory
|
||||||
from djangorestframework.resource import Resource
|
from djangorestframework.resource import Resource
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.contrib.auth import login
|
from django.contrib.auth import login
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
try:
|
|
||||||
import json
|
|
||||||
except ImportError:
|
|
||||||
import simplejson as json
|
|
||||||
|
|
||||||
class MockResource(Resource):
|
class MockResource(Resource):
|
||||||
allowed_methods = ('POST',)
|
allowed_methods = ('POST',)
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
from django.conf.urls.defaults import patterns, url
|
from django.conf.urls.defaults import patterns, url
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from django.utils import simplejson as json
|
||||||
|
|
||||||
from djangorestframework.resource import Resource
|
from djangorestframework.resource import Resource
|
||||||
|
|
||||||
try:
|
|
||||||
import json
|
|
||||||
except ImportError:
|
|
||||||
import simplejson as json
|
|
||||||
|
|
||||||
|
|
||||||
class MockResource(Resource):
|
class MockResource(Resource):
|
||||||
"""Mock resource which simply returns a URL, so that we can ensure that reversed URLs are fully qualified"""
|
"""Mock resource which simply returns a URL, so that we can ensure that reversed URLs are fully qualified"""
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.utils import simplejson as json
|
||||||
|
|
||||||
|
from djangorestframework.compat import RequestFactory
|
||||||
|
|
||||||
from blogpost import views, models
|
from blogpost import views, models
|
||||||
import blogpost
|
import blogpost
|
||||||
|
|
||||||
#import json
|
|
||||||
#from rest.utils import xml2dict, dict2xml
|
|
||||||
|
|
||||||
class AcceptHeaderTests(TestCase):
|
class AcceptHeaderTests(TestCase):
|
||||||
"""Test correct behaviour of the Accept header as specified by RFC 2616:
|
"""Test correct behaviour of the Accept header as specified by RFC 2616:
|
||||||
|
@ -164,11 +166,7 @@ class AllowedMethodsTests(TestCase):
|
||||||
|
|
||||||
|
|
||||||
#above testcases need to probably moved to the core
|
#above testcases need to probably moved to the core
|
||||||
from djangorestframework.compat import RequestFactory
|
|
||||||
try:
|
|
||||||
import json
|
|
||||||
except ImportError:
|
|
||||||
import simplejson as json
|
|
||||||
|
|
||||||
class TestRotation(TestCase):
|
class TestRotation(TestCase):
|
||||||
"""For the example the maximum amount of Blogposts is capped off at views.MAX_POSTS.
|
"""For the example the maximum amount of Blogposts is capped off at views.MAX_POSTS.
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from django.utils import simplejson as json
|
||||||
from djangorestframework.compat import RequestFactory
|
from djangorestframework.compat import RequestFactory
|
||||||
from pygments_api import views
|
from pygments_api import views
|
||||||
import tempfile, shutil
|
import tempfile, shutil
|
||||||
|
|
||||||
try:
|
|
||||||
import json
|
|
||||||
except ImportError:
|
|
||||||
import simplejson as json
|
|
||||||
|
|
||||||
class TestPygmentsExample(TestCase):
|
class TestPygmentsExample(TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user