THRIFT-3503 Enable py:utf8string by default
This closes #779
diff --git a/test/py/FastbinaryTest.py b/test/py/FastbinaryTest.py
index 0583373..9d258fd 100755
--- a/test/py/FastbinaryTest.py
+++ b/test/py/FastbinaryTest.py
@@ -26,6 +26,8 @@
# TODO(dreiss): Test error cases. Check for memory leaks.
import math
+import os
+import sys
import timeit
from copy import deepcopy
@@ -54,7 +56,7 @@
ooe1.integer64 = 6000 * 1000 * 1000
ooe1.double_precision = math.pi
ooe1.some_characters = "Debug THIS!"
-ooe1.zomg_unicode = "\xd7\n\a\t"
+ooe1.zomg_unicode = u"\xd7\n\a\t"
ooe2 = OneOfEach()
ooe2.integer16 = 16
@@ -62,11 +64,15 @@
ooe2.integer64 = 64
ooe2.double_precision = (math.sqrt(5) + 1) / 2
ooe2.some_characters = ":R (me going \"rrrr\")"
-ooe2.zomg_unicode = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"\
- "\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe"\
- "\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e"\
- "\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba"\
- "\xc7\x83\xe2\x80\xbc"
+ooe2.zomg_unicode = u"\xd3\x80\xe2\x85\xae\xce\x9d\x20"\
+ u"\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe"\
+ u"\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e"\
+ u"\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba"\
+ u"\xc7\x83\xe2\x80\xbc"
+
+if sys.version_info[0] == 2 and os.environ.get('THRIFT_TEST_PY_NO_UTF8STRINGS'):
+ ooe1.zomg_unicode = ooe1.zomg_unicode.encode('utf8')
+ ooe2.zomg_unicode = ooe2.zomg_unicode.encode('utf8')
hm = HolyMoley(**{"big": [], "contain": set(), "bonks": {}})
hm.big.append(ooe1)