Skip to content

Commit 02851c2

Browse files
gh-105539: Fix ResourceWarning from unclosed SQLite connection in tests.
Follow up to 1a1bfc2. Co-authored-by: Erlend E. Aasland <[email protected]>
1 parent 79fdacc commit 02851c2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Lib/test/test_sqlite3/test_backup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def progress(status, remaining, total):
137137
raise SystemError('nearly out of space')
138138

139139
with self.assertRaises(SystemError) as err:
140-
with sqlite.connect(':memory:') as bck:
140+
with memory_database() as bck:
141141
self.cx.backup(bck, progress=progress)
142142
self.assertEqual(str(err.exception), 'nearly out of space')
143143

Lib/test/test_sqlite3/test_dbapi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from test.support.os_helper import TESTFN, TESTFN_UNDECODABLE, unlink, temp_dir, FakePath
4141

4242
from .util import memory_database, cx_limit
43+
from .util import MemoryDatabaseMixin
4344

4445

4546
class ModuleTests(unittest.TestCase):
@@ -1740,10 +1741,9 @@ def test_closed_call(self):
17401741
self.check(self.con)
17411742

17421743

1743-
class ClosedCurTests(unittest.TestCase):
1744+
class ClosedCurTests(MemoryDatabaseMixin, unittest.TestCase):
17441745
def test_closed(self):
1745-
con = sqlite.connect(":memory:")
1746-
cur = con.cursor()
1746+
cur = self.cx.cursor()
17471747
cur.close()
17481748

17491749
for method_name in ("execute", "executemany", "executescript", "fetchall", "fetchmany", "fetchone"):

0 commit comments

Comments
 (0)