Skip to content

Commit

Permalink
pytest: don't copy db to query it.
Browse files Browse the repository at this point in the history
Should be safe to do in-place.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Aug 26, 2021
1 parent 5bf2b5c commit 8f782b0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions tests/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import psycopg2
import random
import re
import shutil
import signal
import sqlite3
import string
Expand All @@ -24,13 +23,12 @@ def get_dsn(self):
return None

def query(self, query):
orig = os.path.join(self.path)
copy = self.path + ".copy"
shutil.copyfile(orig, copy)
db = sqlite3.connect(copy)
db = sqlite3.connect(self.path)

db.row_factory = sqlite3.Row
c = db.cursor()
# Don't get upset by concurrent writes; wait for up to 5 seconds!
c.execute("PRAGMA busy_timeout = 5000")
c.execute(query)
rows = c.fetchall()

Expand Down

0 comments on commit 8f782b0

Please sign in to comment.