Skip to content

Commit 8f782b0

Browse files
committed
pytest: don't copy db to query it.
Should be safe to do in-place. Signed-off-by: Rusty Russell <[email protected]>
1 parent 5bf2b5c commit 8f782b0

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tests/db.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import psycopg2
77
import random
88
import re
9-
import shutil
109
import signal
1110
import sqlite3
1211
import string
@@ -24,13 +23,12 @@ def get_dsn(self):
2423
return None
2524

2625
def query(self, query):
27-
orig = os.path.join(self.path)
28-
copy = self.path + ".copy"
29-
shutil.copyfile(orig, copy)
30-
db = sqlite3.connect(copy)
26+
db = sqlite3.connect(self.path)
3127

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

0 commit comments

Comments
 (0)