Skip to content

Commit bf6980f

Browse files
committed
test: support both Python 2 & 3 in the test runner
Python 2 going to its real EOL and it is often easier to get Python 3 on a certain system rather than Python 2. The test runner layer, which is written in Python is quite thin, so it worth re-write it to support both Python 2 and Python 3.
1 parent 2fdbe88 commit bf6980f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/tarantool_server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,17 @@ def execute_no_reconnect(self, command):
9595
if not command:
9696
return
9797
cmd = command.replace('\n', ' ') + '\n'
98-
self.socket.sendall(cmd)
98+
self.socket.sendall(cmd.encode())
9999

100100
bufsiz = 4096
101-
res = ""
101+
res = b""
102102

103103
while True:
104104
buf = self.socket.recv(bufsiz)
105105
if not buf:
106106
break
107107
res = res + buf
108-
if (res.rfind("\n...\n") >= 0 or res.rfind("\r\n...\r\n") >= 0):
108+
if (res.rfind(b"\n...\n") >= 0 or res.rfind(b"\r\n...\r\n") >= 0):
109109
break
110110

111111
return yaml.safe_load(res)
@@ -245,7 +245,7 @@ def start(self):
245245
self.generate_configuration()
246246
if self.script:
247247
shutil.copy(self.script, self.script_dst)
248-
os.chmod(self.script_dst, 0777)
248+
os.chmod(self.script_dst, 0o777)
249249
args = self.prepare_args()
250250
self.process = subprocess.Popen(args,
251251
cwd = self.vardir,

test-run.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python2.7
1+
#!/usr/bin/env python
22

33
import os
44
import sys
@@ -15,7 +15,7 @@
1515
def read_popen(cmd):
1616
path = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
1717
path.wait()
18-
return path.stdout.read()
18+
return path.stdout.read().decode()
1919

2020
def read_popen_config(cmd):
2121
cmd = os.environ.get('PHP_CONFIG', 'php-config') + ' ' + cmd
@@ -111,9 +111,9 @@ def main():
111111
cmd = cmd + 'sudo dtruss ' + find_php_bin()
112112
cmd = cmd + ' -c tarantool.ini {0}'.format(test_lib_path)
113113
else:
114-
print find_php_bin()
114+
print(find_php_bin())
115115
cmd = '{0} -c tarantool.ini {1}'.format(find_php_bin(), test_lib_path)
116-
print cmd
116+
print(cmd)
117117

118118
print('Running "%s" with "%s"' % (cmd, php_ini))
119119
proc = subprocess.Popen(cmd, shell=True, cwd=test_cwd)

0 commit comments

Comments
 (0)