Skip to content

Commit 1bd88c8

Browse files
committed
Port tests to python3
1 parent eca9f7b commit 1bd88c8

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

test/testsuits/base/supervisor.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,33 @@ def run(self, program, stdin=None, extra_options=None):
1919
if extra_options is None:
2020
extra_options = []
2121

22-
options = extra_options + [program]
22+
if isinstance(program, (list, tuple)):
23+
options = extra_options + list(program)
24+
else:
25+
options = extra_options + [program]
26+
options = list(map(str, options))
27+
28+
if stdin is not None:
29+
stdin = stdin.encode('utf-8')
2330

24-
print "running:\n{}\n".format(" ".join([self.SUPERVISOR_BIN] + options))
31+
print("running:\n{}\n".format(" ".join([self.SUPERVISOR_BIN] + options)))
2532
process = subprocess.Popen([self.SUPERVISOR_BIN] + options,
2633
stdin=subprocess.PIPE,
2734
stdout=subprocess.PIPE,
2835
stderr=subprocess.PIPE)
2936
(stdout, stderr) = process.communicate(stdin)
37+
stdout = stdout.decode('utf-8')
38+
stderr = stderr.decode('utf-8')
3039

3140
if process.poll() is None:
3241
process.kill()
3342
process.poll()
34-
print "result: {}\n\nstdout:\n{}\nstderr:\n{}\n".format(process.poll(), stdout.strip(), stderr.strip())
43+
print("result: {}\n\nstdout:\n{}\nstderr:\n{}\n".format(process.poll(), stdout.strip(), stderr.strip()))
3544

3645
result = self.Result()
3746
self.parse_results(result, stdout, stderr)
38-
result.stdout = map(lambda s: s.strip(), stdout.split('\n'))
39-
result.stderr = map(lambda s: s.strip(), stderr.split('\n')[:-3])
47+
result.stdout = list(map(lambda s: s.strip(), stdout.split('\n')))
48+
result.stderr = list(map(lambda s: s.strip(), stderr.split('\n')[:-3]))
4049
result.supervisor_return_code = process.returncode
4150
return result
4251

test/testsuits/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python2
1+
#!/usr/bin/env python3
22

33
import nose
44

0 commit comments

Comments
 (0)