pytest: Minor cleanup

Now using assertRaisesRegex instead of try-except and added restart to
nodes.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2017-12-13 13:44:09 +01:00
committed by Rusty Russell
parent a8a6d1d669
commit e154f4a019
2 changed files with 31 additions and 33 deletions

View File

@@ -79,8 +79,8 @@ class TailableProc(object):
self.proc.wait()
self.thread.join()
if failed:
raise(ValueError("Process '{}' did not cleanly shutdown".format(self.proc.pid)))
if self.proc.returncode:
raise ValueError("Process '{}' did not cleanly shutdown: return code {}".format(self.proc.pid, rc))
return self.proc.returncode
@@ -364,3 +364,17 @@ class LightningNode(object):
raise ValueError("Node did not exit cleanly, rc={}".format(rc))
else:
return rc
def restart(self, timeout=10, clean=True):
"""Stop and restart the lightning node.
Keyword arguments:
timeout: number of seconds to wait for a shutdown
clean: whether to issue a `stop` RPC command before killing
"""
if clean:
self.stop(timeout)
else:
self.daemon.stop()
self.daemon.start()