Skip to content

Commit

Permalink
[3.10] pythongh-93795: Use test.support TESTFN/unlink in sqlite3 tests (
Browse files Browse the repository at this point in the history
pythonGH-93796).

(cherry picked from commit d773c6e)

Co-authored-by: Erlend Egeberg Aasland <[email protected]>
  • Loading branch information
erlend-aasland committed Jun 14, 2022
1 parent 2229d34 commit de0bc5a
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions Lib/sqlite3/test/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,31 @@
import os, unittest
import sqlite3 as sqlite

def get_db_path():
return "sqlite_testdb"
from test.support import LOOPBACK_TIMEOUT
from test.support.os_helper import TESTFN, unlink


TIMEOUT = LOOPBACK_TIMEOUT / 10


class TransactionTests(unittest.TestCase):
def setUp(self):
try:
os.remove(get_db_path())
except OSError:
pass

self.con1 = sqlite.connect(get_db_path(), timeout=0.1)
self.con1 = sqlite.connect(TESTFN, timeout=TIMEOUT)
self.cur1 = self.con1.cursor()

self.con2 = sqlite.connect(get_db_path(), timeout=0.1)
self.con2 = sqlite.connect(TESTFN, timeout=TIMEOUT)
self.cur2 = self.con2.cursor()

def tearDown(self):
self.cur1.close()
self.con1.close()
try:
self.cur1.close()
self.con1.close()

self.cur2.close()
self.con2.close()
self.cur2.close()
self.con2.close()

try:
os.unlink(get_db_path())
except OSError:
pass
finally:
unlink(TESTFN)

def test_dml_does_not_auto_commit_before(self):
self.cur1.execute("create table test(i)")
Expand Down

0 comments on commit de0bc5a

Please sign in to comment.