pytest: Make the directory of the NodeFactory configurable

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2018-05-04 18:27:07 +02:00
committed by Rusty Russell
parent 727d115296
commit bbeb44faac

View File

@@ -95,12 +95,17 @@ def teardown_bitcoind():
class NodeFactory(object):
"""A factory to setup and start `lightningd` daemons.
"""
def __init__(self, testname, bitcoind, executor):
def __init__(self, testname, bitcoind, executor, directory=None):
self.testname = testname
self.next_id = 1
self.nodes = []
self.executor = executor
self.bitcoind = bitcoind
if directory is not None:
self.directory = directory
else:
self.directory = os.path.join(TEST_DIR, testname)
self.lock = threading.Lock()
def split_options(self, opts):
"""Split node options from cli options
@@ -148,7 +153,7 @@ class NodeFactory(object):
self.next_id += 1
lightning_dir = os.path.join(
TEST_DIR, self.testname, "lightning-{}/".format(node_id))
self.directory, "lightning-{}/".format(node_id))
if os.path.exists(lightning_dir):
shutil.rmtree(lightning_dir)