Support python3 in test.py (#494)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@@ -32,13 +32,14 @@ def check_call(cmd, **args):
|
|||||||
if type(cmd) != list:
|
if type(cmd) != list:
|
||||||
cmd = cmd.split()
|
cmd = cmd.split()
|
||||||
print('running: %s' % cmd)
|
print('running: %s' % cmd)
|
||||||
|
args['universal_newlines'] = True
|
||||||
subprocess.check_call(cmd, **args)
|
subprocess.check_call(cmd, **args)
|
||||||
|
|
||||||
|
|
||||||
def checked_call_with_output(cmd, expected=None, unexpected=None, stderr=None):
|
def checked_call_with_output(cmd, expected=None, unexpected=None, stderr=None):
|
||||||
cmd = cmd.split(' ')
|
cmd = cmd.split(' ')
|
||||||
print('running: %s' % cmd)
|
print('running: %s' % cmd)
|
||||||
stdout = subprocess.check_output(cmd, stderr=stderr)
|
stdout = subprocess.check_output(cmd, stderr=stderr, universal_newlines=True)
|
||||||
if expected:
|
if expected:
|
||||||
for x in listify(expected):
|
for x in listify(expected):
|
||||||
assert x in stdout, 'call had the right output: ' + stdout + '\n[[[' + x + ']]]'
|
assert x in stdout, 'call had the right output: ' + stdout + '\n[[[' + x + ']]]'
|
||||||
@@ -48,7 +49,7 @@ def checked_call_with_output(cmd, expected=None, unexpected=None, stderr=None):
|
|||||||
|
|
||||||
|
|
||||||
def failing_call_with_output(cmd, expected):
|
def failing_call_with_output(cmd, expected):
|
||||||
proc = subprocess.Popen(cmd.split(' '), stdout=subprocess.PIPE)
|
proc = subprocess.Popen(cmd.split(' '), stdout=subprocess.PIPE, universal_newlines=True)
|
||||||
stdout, stderr = proc.communicate()
|
stdout, stderr = proc.communicate()
|
||||||
assert proc.returncode, 'call must have failed'
|
assert proc.returncode, 'call must have failed'
|
||||||
assert expected in stdout, 'call did not have the right output'
|
assert expected in stdout, 'call did not have the right output'
|
||||||
|
|||||||
Reference in New Issue
Block a user