Skip to content
Prev Previous commit
Next Next commit
Split open tests into their own test case, and cleanup more explicitly
  • Loading branch information
Erlend E. Aasland committed Jun 2, 2021
commit 6cb435b8dacd39b3e0dc04b2280b5ddfb48e4af9
10 changes: 8 additions & 2 deletions Lib/sqlite3/test/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,16 @@ def test_in_transaction_ro(self):
with self.assertRaises(AttributeError):
self.cx.in_transaction = True


class OpenTests(unittest.TestCase):
def tearDown(self):
import gc
gc.collect()
unlink(TESTFN)

def test_open_with_path_like_object(self):
""" Checks that we can successfully connect to a database using an object that
is PathLike, i.e. has __fspath__(). """
self.addCleanup(unlink, TESTFN)
class Path:
def __fspath__(self):
return TESTFN
Expand All @@ -182,7 +188,6 @@ def __fspath__(self):
cx.execute('create table test(id integer)')

def test_open_uri(self):
self.addCleanup(unlink, TESTFN)
with sqlite.connect(TESTFN) as cx:
cx.execute('create table test(id integer)')
with sqlite.connect('file:' + TESTFN, uri=True) as cx:
Expand Down Expand Up @@ -942,6 +947,7 @@ def suite():
CursorTests,
ExtensionTests,
ModuleTests,
OpenTests,
SqliteOnConflictTests,
ThreadTests,
]
Expand Down