aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/sqlite3/test/hooks.py
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-06-03 18:38:19 +0200
committerGitHub <noreply@github.com>2021-06-03 09:38:19 -0700
commitd88b47b5a396aa8d66f9a0e6b13a0825d59d0eff (patch)
treed932a399ff6b69078f5a0bf5874b4e7e438a6b69 /Lib/sqlite3/test/hooks.py
parent2c1e2583fdc4db6b43d163239ea42b0e8394171f (diff)
downloadcpython-d88b47b5a396aa8d66f9a0e6b13a0825d59d0eff.tar.gz
cpython-d88b47b5a396aa8d66f9a0e6b13a0825d59d0eff.zip
bpo-42213: Remove redundant cyclic GC hack in sqlite3 (GH-26517)
The sqlite3 module now fully implements the GC protocol, so there's no need for this workaround anymore. - Add and use managed resource helper for connections using TESTFN - Sort test imports - Split open-tests into their own test case Automerge-Triggered-By: GH:vstinner
Diffstat (limited to 'Lib/sqlite3/test/hooks.py')
-rw-r--r--Lib/sqlite3/test/hooks.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py
index 8c60bdcf5d7..520a5b9f11c 100644
--- a/Lib/sqlite3/test/hooks.py
+++ b/Lib/sqlite3/test/hooks.py
@@ -254,11 +254,15 @@ class TraceCallbackTests(unittest.TestCase):
self.addCleanup(unlink, TESTFN)
con1 = sqlite.connect(TESTFN, isolation_level=None)
con2 = sqlite.connect(TESTFN)
- con1.set_trace_callback(trace)
- cur = con1.cursor()
- cur.execute(queries[0])
- con2.execute("create table bar(x)")
- cur.execute(queries[1])
+ try:
+ con1.set_trace_callback(trace)
+ cur = con1.cursor()
+ cur.execute(queries[0])
+ con2.execute("create table bar(x)")
+ cur.execute(queries[1])
+ finally:
+ con1.close()
+ con2.close()
self.assertEqual(traced_statements, queries)