Skip to content

Commit

Permalink
Encode UTF text only if in Python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
pferate committed Mar 9, 2015
1 parent 2b14022 commit ca397a7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/test_json_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ def test_json_build_query(self):

query_dict = parse_qs(query[1:])
self.assertEqual(query_dict['foo'], ['1'])
self.assertEqual(query_dict['bar'], [u'\N{COMET}'.encode('utf-8')])
if six.PY3:
# Python 3, no need to encode
self.assertEqual(query_dict['bar'], [u'\N{COMET}'])
else:
# Python 2, encode string
self.assertEqual(query_dict['bar'], [u'\N{COMET}'.encode('utf-8')])
self.assertEqual(query_dict['baz'], ['fe', 'fi', 'fo', 'fum'])
self.assertTrue('qux' not in query_dict)
self.assertEqual(body, '{}')
Expand Down

0 comments on commit ca397a7

Please sign in to comment.