Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd773c6e

Browse files
gh-93795: Use test.support TESTFN/unlink in sqlite3 tests (#93796)
1 parentcdf7097 commitd773c6e

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

‎Lib/test/test_sqlite3/test_transactions.py‎

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,33 @@
2323
importos,unittest
2424
importsqlite3assqlite
2525

26+
fromtest.supportimportLOOPBACK_TIMEOUT
27+
fromtest.support.os_helperimportTESTFN,unlink
28+
2629
fromtest.test_sqlite3.test_dbapiimportmemory_database
2730

28-
defget_db_path():
29-
return"sqlite_testdb"
31+
32+
TIMEOUT=LOOPBACK_TIMEOUT/10
33+
3034

3135
classTransactionTests(unittest.TestCase):
3236
defsetUp(self):
33-
try:
34-
os.remove(get_db_path())
35-
exceptOSError:
36-
pass
37-
38-
self.con1=sqlite.connect(get_db_path(),timeout=0.1)
37+
self.con1=sqlite.connect(TESTFN,timeout=TIMEOUT)
3938
self.cur1=self.con1.cursor()
4039

41-
self.con2=sqlite.connect(get_db_path(),timeout=0.1)
40+
self.con2=sqlite.connect(TESTFN,timeout=TIMEOUT)
4241
self.cur2=self.con2.cursor()
4342

4443
deftearDown(self):
45-
self.cur1.close()
46-
self.con1.close()
44+
try:
45+
self.cur1.close()
46+
self.con1.close()
4747

48-
self.cur2.close()
49-
self.con2.close()
48+
self.cur2.close()
49+
self.con2.close()
5050

51-
try:
52-
os.unlink(get_db_path())
53-
exceptOSError:
54-
pass
51+
finally:
52+
unlink(TESTFN)
5553

5654
deftest_dml_does_not_auto_commit_before(self):
5755
self.cur1.execute("create table test(i)")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp