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

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