diff options
author | Erlend Egeberg Aasland <erlend.aasland@protonmail.com> | 2022-06-14 15:41:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-14 15:41:50 (GMT) |
commit | 8b36ce69acc5999d5eefc289e29984df5ff216aa (patch) | |
tree | ad91492c507963f34cf6e937e48048af91ae9234 /Lib/sqlite3 | |
parent | 2229d34a6ef9c03e476882f46bba4d7c83552d1e (diff) | |
download | cpython-8b36ce69acc5999d5eefc289e29984df5ff216aa.zip cpython-8b36ce69acc5999d5eefc289e29984df5ff216aa.tar.gz cpython-8b36ce69acc5999d5eefc289e29984df5ff216aa.tar.bz2 |
[3.10] gh-93795: Use test.support TESTFN/unlink in sqlite3 tests (GH-93796). (#93809)
Diffstat (limited to 'Lib/sqlite3')
-rw-r--r-- | Lib/sqlite3/test/transactions.py | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/Lib/sqlite3/test/transactions.py b/Lib/sqlite3/test/transactions.py index 8028490..4ebc7fb 100644 --- a/Lib/sqlite3/test/transactions.py +++ b/Lib/sqlite3/test/transactions.py @@ -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)") |