Skip to content

Commit 8b36ce6

Browse files
[3.10] gh-93795: Use test.support TESTFN/unlink in sqlite3 tests (GH-93796). (#93809)
1 parent 2229d34 commit 8b36ce6

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

Lib/sqlite3/test/transactions.py

+15-17
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,31 @@
2323
import os, unittest
2424
import sqlite3 as sqlite
2525

26-
def get_db_path():
27-
return "sqlite_testdb"
26+
from test.support import LOOPBACK_TIMEOUT
27+
from test.support.os_helper import TESTFN, unlink
28+
29+
30+
TIMEOUT = LOOPBACK_TIMEOUT / 10
31+
2832

2933
class TransactionTests(unittest.TestCase):
3034
def setUp(self):
31-
try:
32-
os.remove(get_db_path())
33-
except OSError:
34-
pass
35-
36-
self.con1 = sqlite.connect(get_db_path(), timeout=0.1)
35+
self.con1 = sqlite.connect(TESTFN, timeout=TIMEOUT)
3736
self.cur1 = self.con1.cursor()
3837

39-
self.con2 = sqlite.connect(get_db_path(), timeout=0.1)
38+
self.con2 = sqlite.connect(TESTFN, timeout=TIMEOUT)
4039
self.cur2 = self.con2.cursor()
4140

4241
def tearDown(self):
43-
self.cur1.close()
44-
self.con1.close()
42+
try:
43+
self.cur1.close()
44+
self.con1.close()
4545

46-
self.cur2.close()
47-
self.con2.close()
46+
self.cur2.close()
47+
self.con2.close()
4848

49-
try:
50-
os.unlink(get_db_path())
51-
except OSError:
52-
pass
49+
finally:
50+
unlink(TESTFN)
5351

5452
def test_dml_does_not_auto_commit_before(self):
5553
self.cur1.execute("create table test(i)")

0 commit comments

Comments
 (0)