pytest: Use the file object and don't use print without line-endings

This commit is contained in:
Christian Decker 2018-08-06 21:52:38 +02:00 committed by Rusty Russell
parent ae99e493b8
commit 90f74907f9
2 changed files with 4 additions and 6 deletions

View File

@ -164,8 +164,7 @@ def printCrashLog(node):
errors, fname = getCrashLog(node) errors, fname = getCrashLog(node)
if errors: if errors:
print("-" * 10, "{} (last 50 lines)".format(fname), "-" * 10) print("-" * 10, "{} (last 50 lines)".format(fname), "-" * 10)
for l in errors[-50:]: print("".join(errors[-50:]))
print(l, end='')
print("-" * 80) print("-" * 80)
return 1 if errors else 0 return 1 if errors else 0

View File

@ -679,10 +679,9 @@ class NodeFactory(object):
if fake_bitcoin_cli: if fake_bitcoin_cli:
cli = os.path.join(lightning_dir, "fake-bitcoin-cli") cli = os.path.join(lightning_dir, "fake-bitcoin-cli")
with open(cli, "w") as text_file: with open(cli, "w") as text_file:
print("""#! /bin/sh text_file.write('#! /bin/sh\n'
! [ -f bitcoin-cli-fail ] || exit `cat bitcoin-cli-fail` '! [ -f bitcoin-cli-fail ] || exit `cat bitcoin-cli-fail`\n'
exec bitcoin-cli "$@" 'exec bitcoin-cli "$@"\n')
""", file=text_file)
os.chmod(cli, os.stat(cli).st_mode | stat.S_IEXEC) os.chmod(cli, os.stat(cli).st_mode | stat.S_IEXEC)
daemon.opts['bitcoin-cli'] = cli daemon.opts['bitcoin-cli'] = cli