diff options
author | Hanaasagi <ambiguous404@gmail.com> | 2019-01-05 13:30:04 +0900 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2019-01-31 14:24:17 +0100 |
commit | 0607494b142d2d3276c3aa9559d5e8c0674fe95f (patch) | |
tree | bfd7106e102697384eaf40d4ff3b92cb10854fe6 | |
parent | c8179b28d93b2875a31866c6b84a9b5b59c0c8b4 (diff) | |
download | bottle-0607494b142d2d3276c3aa9559d5e8c0674fe95f.tar.gz |
fix failed test caused by ujson
-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): |