From ca397a7a27ccf883dc7d14484bf7588ea023cc8c Mon Sep 17 00:00:00 2001 From: Pat Ferate Date: Tue, 3 Mar 2015 18:06:15 -0800 Subject: [PATCH] Encode UTF text only if in Python 2 --- tests/test_json_model.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_json_model.py b/tests/test_json_model.py index c4c39010cb9..b1986523f16 100644 --- a/tests/test_json_model.py +++ b/tests/test_json_model.py @@ -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, '{}')