mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
gh-93795: Use test.support TESTFN/unlink in sqlite3 tests (#93796)
This commit is contained in:
parent
cdf7097612
commit
d773c6e95a
1 changed files with 16 additions and 18 deletions
|
@ -23,35 +23,33 @@
|
||||||
import os, unittest
|
import os, unittest
|
||||||
import sqlite3 as sqlite
|
import sqlite3 as sqlite
|
||||||
|
|
||||||
|
from test.support import LOOPBACK_TIMEOUT
|
||||||
|
from test.support.os_helper import TESTFN, unlink
|
||||||
|
|
||||||
from test.test_sqlite3.test_dbapi import memory_database
|
from test.test_sqlite3.test_dbapi import memory_database
|
||||||
|
|
||||||
def get_db_path():
|
|
||||||
return "sqlite_testdb"
|
TIMEOUT = LOOPBACK_TIMEOUT / 10
|
||||||
|
|
||||||
|
|
||||||
class TransactionTests(unittest.TestCase):
|
class TransactionTests(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
try:
|
self.con1 = sqlite.connect(TESTFN, timeout=TIMEOUT)
|
||||||
os.remove(get_db_path())
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
self.con1 = sqlite.connect(get_db_path(), timeout=0.1)
|
|
||||||
self.cur1 = self.con1.cursor()
|
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()
|
self.cur2 = self.con2.cursor()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
try:
|
||||||
self.cur1.close()
|
self.cur1.close()
|
||||||
self.con1.close()
|
self.con1.close()
|
||||||
|
|
||||||
self.cur2.close()
|
self.cur2.close()
|
||||||
self.con2.close()
|
self.con2.close()
|
||||||
|
|
||||||
try:
|
finally:
|
||||||
os.unlink(get_db_path())
|
unlink(TESTFN)
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def test_dml_does_not_auto_commit_before(self):
|
def test_dml_does_not_auto_commit_before(self):
|
||||||
self.cur1.execute("create table test(i)")
|
self.cur1.execute("create table test(i)")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue