Skip to content

Commit c7707be

Browse files
committed
gh-145040: Close connections in tests to avoid ResourceWarning
1 parent 36ea504 commit c7707be

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/test/test_sqlite3/test_userfunctions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ def inverse(self, value):
613613
"(ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t"
614614
)
615615
list(cursor)
616+
con.close()
616617

617618

618619
class AggregateTests(unittest.TestCase):
@@ -773,6 +774,7 @@ def finalize(self):
773774
msg = "from within a callback"
774775
with self.assertRaisesRegex(sqlite.ProgrammingError, msg):
775776
con.execute("SELECT agg_close(x) FROM t")
777+
con.close()
776778

777779
def test_close_conn_in_nested_callback(self):
778780
# gh-145040: close() must be prevented even in nested callbacks.
@@ -838,6 +840,7 @@ def close_conn(x):
838840
with self.assertRaisesRegex(sqlite.ProgrammingError, msg):
839841
con.executemany("INSERT INTO t VALUES(close_conn(?))",
840842
[(i,) for i in range(10)])
843+
con.close()
841844

842845
def test_close_conn_in_progress_handler_during_iternext(self):
843846
# gh-145040: closing connection in progress handler during iteration.
@@ -865,6 +868,7 @@ def close_progress():
865868
pass
866869
del cursor
867870
gc_collect()
871+
con.close()
868872

869873
def test_close_conn_in_collation_callback(self):
870874
# gh-145040: closing connection in collation callback.
@@ -891,6 +895,7 @@ def evil_collation(a, b):
891895
con.execute(
892896
"SELECT * FROM t ORDER BY x COLLATE evil_coll"
893897
)
898+
con.close()
894899

895900

896901
class AuthorizerTests(unittest.TestCase):

0 commit comments

Comments
 (0)