parent
e97e9aedaa
commit
f552316681
|
@ -14,7 +14,10 @@
|
|||
|
||||
"""HTTPError exception class."""
|
||||
|
||||
import json
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
import xml.etree.ElementTree as et
|
||||
|
||||
try:
|
||||
|
@ -170,8 +173,7 @@ class HTTPError(Exception):
|
|||
"""
|
||||
|
||||
obj = self.to_dict(OrderedDict)
|
||||
return json.dumps(obj, indent=4, separators=(',', ': '),
|
||||
ensure_ascii=False)
|
||||
return json.dumps(obj, ensure_ascii=False)
|
||||
|
||||
def to_xml(self):
|
||||
"""Returns an XML-encoded representation of the error.
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
"""Request class."""
|
||||
|
||||
from datetime import datetime
|
||||
import json
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
try:
|
||||
# NOTE(kgrifs): In Python 2.6 and 2.7, socket._fileobject is a
|
||||
|
|
|
@ -32,7 +32,10 @@ This package includes utilities for simulating HTTP requests against a
|
|||
WSGI callable, without having to stand up a WSGI server.
|
||||
"""
|
||||
|
||||
import json
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
import platform
|
||||
import re
|
||||
import wsgiref.validate
|
||||
|
|
|
@ -24,7 +24,10 @@ directly from the `testing` package::
|
|||
|
||||
"""
|
||||
|
||||
from json import dumps as json_dumps
|
||||
try:
|
||||
from ujson import dumps as json_dumps
|
||||
except ImportError:
|
||||
from json import dumps as json_dumps
|
||||
|
||||
import falcon
|
||||
from .helpers import rand_string
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import functools
|
||||
import json
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
import falcon
|
||||
from falcon import testing
|
||||
|
@ -179,11 +182,11 @@ class TestHooks(testing.TestCase):
|
|||
def test_output_validator(self):
|
||||
result = self.simulate_get()
|
||||
self.assertEqual(result.status_code, 723)
|
||||
self.assertEqual(result.text, '{\n "title": "Tricky"\n}')
|
||||
self.assertEqual(result.text, json.dumps({'title': 'Tricky'}))
|
||||
|
||||
def test_serializer(self):
|
||||
result = self.simulate_put()
|
||||
self.assertEqual('{"animal": "falcon"}', result.text)
|
||||
self.assertEqual(result.text, json.dumps({'animal': 'falcon'}))
|
||||
|
||||
def test_hook_as_callable_class(self):
|
||||
result = self.simulate_post()
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import functools
|
||||
import io
|
||||
import json
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
import falcon
|
||||
import falcon.testing as testing
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import json
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
import logging
|
||||
import uuid
|
||||
from wsgiref import simple_server
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
# -*- coding: utf-8
|
||||
|
||||
import datetime
|
||||
import json
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
import xml.etree.ElementTree as et
|
||||
|
||||
import ddt
|
||||
|
@ -284,7 +287,7 @@ class TestHTTPError(testing.TestBase):
|
|||
def test_no_description_json(self):
|
||||
body = self.simulate_request('/fail', method='PATCH')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(body, [b'{\n "title": "400 Bad Request"\n}'])
|
||||
self.assertEqual(body, [json.dumps({'title': '400 Bad Request'}).encode('utf8')])
|
||||
|
||||
def test_no_description_xml(self):
|
||||
body = self.simulate_request('/fail', method='PATCH',
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
from datetime import datetime
|
||||
import json
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
import falcon
|
||||
import falcon.testing as testing
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
from datetime import date
|
||||
import json
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
import ddt
|
||||
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
from datetime import datetime
|
||||
import functools
|
||||
import io
|
||||
import json
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
import random
|
||||
import sys
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import json
|
||||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
import falcon
|
||||
from falcon import testing
|
||||
|
|
Loading…
Reference in New Issue