File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
from bson import ObjectId
4
4
from flask import jsonify
5
+ from six import ensure_str
5
6
6
7
from flask_pymongo .tests .util import FlaskPyMongoTest
7
8
@@ -10,12 +11,12 @@ class JSONTest(FlaskPyMongoTest):
10
11
11
12
def test_it_encodes_json (self ):
12
13
resp = jsonify ({"foo" : "bar" })
13
- dumped = json .loads (resp .get_data ())
14
+ dumped = json .loads (ensure_str ( resp .get_data () ))
14
15
self .assertEqual (dumped , {"foo" : "bar" })
15
16
16
17
def test_it_handles_pymongo_types (self ):
17
18
resp = jsonify ({"id" : ObjectId ("5cf29abb5167a14c9e6e12c4" )})
18
- dumped = json .loads (resp .get_data ())
19
+ dumped = json .loads (ensure_str ( resp .get_data () ))
19
20
self .assertEqual (dumped , {"id" : {"$oid" : "5cf29abb5167a14c9e6e12c4" }})
20
21
21
22
def test_it_jsonifies_a_cursor (self ):
@@ -24,5 +25,5 @@ def test_it_jsonifies_a_cursor(self):
24
25
curs = self .mongo .db .rows .find (projection = {"_id" : False }).sort ("foo" )
25
26
26
27
resp = jsonify (curs )
27
- dumped = json .loads (resp .get_data ())
28
+ dumped = json .loads (ensure_str ( resp .get_data () ))
28
29
self .assertEqual ([{"foo" : "bar" }, {"foo" : "baz" }], dumped )
You can’t perform that action at this time.
0 commit comments