python: fix tests, remove intentional debug failures

This commit is contained in:
Gregory Becker
2020-03-31 16:05:52 -07:00
committed by Tamara Dahlgren
parent d53eefa69f
commit 97dc74c727
2 changed files with 11 additions and 17 deletions

View File

@@ -1692,7 +1692,7 @@ def run_test(self, exe, options=[], expected=[], status=None):
for check in expected:
cmd = ' '.join([exe] + options)
msg = "Expected '%s' in output of `%s`" % (check, cmd)
# msg += '\n%s' % output
msg += '\n\nOutput: %s' % output
assert check in output, msg
except ProcessError as err:

View File

@@ -1111,21 +1111,15 @@ def remove_files_from_view(self, view, merge_map):
os.remove(dst)
def test(self):
self.run_test('true', expected=['not in output'])
# guaranteed executable name
# do not use self.command because we are also testing the run env
exe = 'python3' if self.spec.satisfies('@3:') else 'python'
# contains python executable
python = which('python')
assert os.path.dirname(python.path) == os.path.dirname(
self.command.path)
# test hello world
self.run_test(exe, options=['-c', 'print("hello world!")'],
expected=['hello world!'])
# run hello world
output = self.command('-c', 'print("hello world!")',
output=str.split, error=str.split)
assert output == "hello world!"
self.command('-c', 'assert False', output=str.split, error=str.split)
# error = self.command('-c', 'print("Error: failed.")',
# output=str.split, error=str.split)
# assert error.strip() == 'Error: failed.'
# check that the executable comes from the spec prefix
# also checks imports work
self.run_test(exe, options=['-c', 'import sys; print(sys.executable)'],
expected=[self.spec.prefix])