diff options
-rwxr-xr-x | test/test_outputfilter.py | 9 | ||||
-rw-r--r-- | test/test_plugins.py | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/test/test_outputfilter.py b/test/test_outputfilter.py index cb752b1..17c7890 100755 --- a/test/test_outputfilter.py +++ b/test/test_outputfilter.py @@ -6,6 +6,13 @@ import bottle from bottle import tob, touni from .tools import ServerTestBase, tobs, warn +USING_UJSON = True + +try: + import ujson +except ImportError: + USING_UJSON = False + class TestOutputFilter(ServerTestBase): ''' Tests for WSGI functionality, routing and output casting (decorators) ''' @@ -76,6 +83,7 @@ class TestOutputFilter(ServerTestBase): except ImportError: warn("Skipping JSON tests.") + @unittest.skipIf(USING_UJSON, 'ujson do not throw exception in serialize') def test_json_serialization_error(self): """ Verify that 500 errors serializing dictionaries don't return @@ -88,6 +96,7 @@ class TestOutputFilter(ServerTestBase): except ImportError: warn("Skipping JSON tests.") + def test_json_HTTPResponse(self): self.app.route('/')(lambda: bottle.HTTPResponse({'a': 1}, 500)) try: diff --git a/test/test_plugins.py b/test/test_plugins.py index c2609fd..a4f018b 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -2,7 +2,7 @@ import unittest from . import tools -from bottle import HTTPResponse, HTTPError +from bottle import HTTPResponse, HTTPError, json_dumps class MyPlugin(object): @@ -160,8 +160,8 @@ class TestPluginManagement(tools.ServerTestBase): def _(): raise HTTPResponse({'test': 'ko2'}, 402) - self.assertBody(b'{"test": "ko"}', '/return') - self.assertBody(b'{"test": "ko2"}', '/raise') + self.assertBody(json_dumps({'test': 'ko'}), '/return') + self.assertBody(json_dumps({'test': 'ko2'}), '/raise') class TestPluginAPI(tools.ServerTestBase): |