From 45c935ddbae458c7b849c65330184c7238cea0f8 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 24 Jan 2018 15:47:35 +0100 Subject: [PATCH] pytest: Have the db_query helper work on a copy of the DB Signed-off-by: Christian Decker --- tests/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/utils.py b/tests/utils.py index 71d7f88bf..f5d7458ce 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -338,7 +338,12 @@ class LightningNode(object): return [c for c in self.rpc.listchannels()['channels'] if c['active']] def db_query(self, query): - db = sqlite3.connect(os.path.join(self.daemon.lightning_dir, "lightningd.sqlite3")) + from shutil import copyfile + orig = os.path.join(self.daemon.lightning_dir, "lightningd.sqlite3") + copy = os.path.join(self.daemon.lightning_dir, "lightningd-copy.sqlite3") + copyfile(orig, copy) + + db = sqlite3.connect(copy) db.row_factory = sqlite3.Row c = db.cursor() c.execute(query)