Skip to content

Commit 5fda54b

Browse files
committed
python 3.5 test compatibility fix
1 parent 1d66c0a commit 5fda54b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

flask_pymongo/tests/test_json.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from bson import ObjectId
44
from flask import jsonify
5+
from six import ensure_str
56

67
from flask_pymongo.tests.util import FlaskPyMongoTest
78

@@ -10,12 +11,12 @@ class JSONTest(FlaskPyMongoTest):
1011

1112
def test_it_encodes_json(self):
1213
resp = jsonify({"foo": "bar"})
13-
dumped = json.loads(resp.get_data())
14+
dumped = json.loads(ensure_str(resp.get_data()))
1415
self.assertEqual(dumped, {"foo": "bar"})
1516

1617
def test_it_handles_pymongo_types(self):
1718
resp = jsonify({"id": ObjectId("5cf29abb5167a14c9e6e12c4")})
18-
dumped = json.loads(resp.get_data())
19+
dumped = json.loads(ensure_str(resp.get_data()))
1920
self.assertEqual(dumped, {"id": {"$oid": "5cf29abb5167a14c9e6e12c4"}})
2021

2122
def test_it_jsonifies_a_cursor(self):
@@ -24,5 +25,5 @@ def test_it_jsonifies_a_cursor(self):
2425
curs = self.mongo.db.rows.find(projection={"_id": False}).sort("foo")
2526

2627
resp = jsonify(curs)
27-
dumped = json.loads(resp.get_data())
28+
dumped = json.loads(ensure_str(resp.get_data()))
2829
self.assertEqual([{"foo": "bar"}, {"foo": "baz"}], dumped)

0 commit comments

Comments
 (0)