summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@protonmail.com>2022-06-14 15:41:32 (GMT)
committerGitHub <noreply@github.com>2022-06-14 15:41:32 (GMT)
commit7aa4038a6e3c7dca0086eeaf4bcb7c952997f213 (patch)
tree5af1fdc42718f7896d259af11dacab78dac36930
parentef591cf8e3725e74489f4c19ca85b87cf6886852 (diff)
downloadcpython-7aa4038a6e3c7dca0086eeaf4bcb7c952997f213.zip
cpython-7aa4038a6e3c7dca0086eeaf4bcb7c952997f213.tar.gz
cpython-7aa4038a6e3c7dca0086eeaf4bcb7c952997f213.tar.bz2
[3.11] gh-93795: Use test.support TESTFN/unlink in sqlite3 tests (GH-93796) (#93808)
-rw-r--r--Lib/test/test_sqlite3/test_transactions.py32
1 files changed, 15 insertions, 17 deletions
diff --git a/Lib/test/test_sqlite3/test_transactions.py b/Lib/test/test_sqlite3/test_transactions.py
index 040ab1e..21acad8 100644
--- a/Lib/test/test_sqlite3/test_transactions.py
+++ b/Lib/test/test_sqlite3/test_transactions.py
@@ -23,35 +23,33 @@
import os, unittest
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
-def get_db_path():
- return "sqlite_testdb"
+
+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)")