THRIFT-3503 Enable py:utf8string by default
This closes #779
diff --git a/test/py/RunClientServer.py b/test/py/RunClientServer.py
index 8a7ead5..d5ebd6a 100755
--- a/test/py/RunClientServer.py
+++ b/test/py/RunClientServer.py
@@ -72,17 +72,20 @@
return os.path.join(SCRIPT_DIR, fname)
-def setup_pypath(dirs):
- env = copy.copy(os.environ)
+def setup_pypath(libdir, gendir):
+ dirs = [libdir, gendir]
+ env = copy.deepcopy(os.environ)
pypath = env.get('PYTHONPATH', None)
if pypath:
dirs.append(pypath)
env['PYTHONPATH'] = ':'.join(dirs)
+ if gendir.endswith('gen-py-no_utf8strings'):
+ env['THRIFT_TEST_PY_NO_UTF8STRINGS'] = '1'
return env
-def runScriptTest(libdir, genpydir, script):
- env = setup_pypath([libdir, genpydir])
+def runScriptTest(libdir, genbase, genpydir, script):
+ env = setup_pypath(libdir, os.path.join(genbase, genpydir))
script_args = [sys.executable, relfile(script)]
print('\nTesting script: %s\n----' % (' '.join(script_args)))
ret = subprocess.call(script_args, env=env)
@@ -94,8 +97,8 @@
raise Exception("Script subprocess failed, retcode=%d, args: %s" % (ret, ' '.join(script_args)))
-def runServiceTest(libdir, genpydir, server_class, proto, port, use_zlib, use_ssl, verbose):
- env = setup_pypath([libdir, genpydir])
+def runServiceTest(libdir, genbase, genpydir, server_class, proto, port, use_zlib, use_ssl, verbose):
+ env = setup_pypath(libdir, os.path.join(genbase, genpydir))
# Build command line arguments
server_args = [sys.executable, relfile('TestServer.py')]
cli_args = [sys.executable, relfile('TestClient.py')]
@@ -169,7 +172,8 @@
class TestCases(object):
- def __init__(self, libdir, port, gendirs, servers, verbose):
+ def __init__(self, genbase, libdir, port, gendirs, servers, verbose):
+ self.genbase = genbase
self.libdir = libdir
self.port = port
self.verbose = verbose
@@ -200,7 +204,7 @@
if self.verbose > 0:
print('\nTest run #%d: (includes %s) Server=%s, Proto=%s, zlib=%s, SSL=%s'
% (test_count, genpydir, try_server, try_proto, with_zlib, with_ssl))
- runServiceTest(self.libdir, genpydir, try_server, try_proto, self.port, with_zlib, with_ssl, self.verbose)
+ runServiceTest(self.libdir, self.genbase, genpydir, try_server, try_proto, self.port, with_zlib, with_ssl, self.verbose)
if self.verbose > 0:
print('OK: Finished (includes %s) %s / %s proto / zlib=%s / SSL=%s. %d combinations tested.'
% (genpydir, try_server, try_proto, with_zlib, with_ssl, test_count))
@@ -232,7 +236,7 @@
if self.verbose > 0:
print('\nTest run #%d: (includes %s) Server=%s, Proto=%s, zlib=%s, SSL=%s'
% (test_count, genpydir, try_server, try_proto, with_zlib, with_ssl))
- runServiceTest(self.libdir, genpydir, try_server, try_proto, self.port, with_zlib, with_ssl)
+ runServiceTest(self.libdir, self.genbase, genpydir, try_server, try_proto, self.port, with_zlib, with_ssl)
if self.verbose > 0:
print('OK: Finished (includes %s) %s / %s proto / zlib=%s / SSL=%s. %d combinations tested.'
% (genpydir, try_server, try_proto, with_zlib, with_ssl, test_count))
@@ -250,7 +254,7 @@
parser = OptionParser()
parser.add_option('--all', action="store_true", dest='all')
parser.add_option('--genpydirs', type='string', dest='genpydirs',
- default='default,slots,oldstyle,dynamic,dynamicslots',
+ default='default,slots,oldstyle,no_utf8strings,dynamic,dynamicslots',
help='directory extensions for generated code, used as suffixes for \"gen-py-*\" added sys.path for individual tests')
parser.add_option("--port", type="int", dest="port", default=9090,
help="port number for server to listen on")
@@ -262,6 +266,8 @@
help="minimal output")
parser.add_option('-L', '--libdir', dest="libdir", default=default_libdir(),
help="directory path that contains Thrift Python library")
+ parser.add_option('--gen-base', dest="gen_base", default=SCRIPT_DIR,
+ help="directory path that contains Thrift Python library")
parser.set_defaults(verbose=1)
options, args = parser.parse_args()
@@ -278,7 +284,7 @@
print('Unavailable server type "%s", please choose one of: %s' % (args[0], servers))
sys.exit(0)
- tests = TestCases(options.libdir, options.port, generated_dirs, servers, options.verbose)
+ tests = TestCases(options.gen_base, options.libdir, options.port, generated_dirs, servers, options.verbose)
# run tests without a client/server first
print('----------------')
@@ -288,7 +294,7 @@
print('----------------')
for genpydir in generated_dirs:
for script in SCRIPTS:
- runScriptTest(options.libdir, genpydir, script)
+ runScriptTest(options.libdir, options.gen_base, genpydir, script)
print('----------------')
print(' Executing Client/Server tests with various generated code directories')