Skip to content

Commit 5af30d5

Browse files
fix: close leaked InMemoryCatalog connection in test_load_catalog_in_memory
Fixes unclosed sqlite3.Connection ResourceWarning that surfaces during test setup in Python 3.14 CI runs. The test was creating an InMemoryCatalog via load_catalog() without explicitly closing it, violating the explicit cleanup pattern established for issue apache#2530. The warning surfaces later (during setup of the next test in execution order) due to Python's deferred garbage collection of the unreferenced catalog object, causing pytest to attribute it to an unrelated test module. Root cause confirmed by investigation: this test was the only unclosed catalog instance remaining in the tests/ suite. Changes: - Bind the returned catalog to a variable and close it explicitly via try/finally, mirroring the pattern already established in test_bigquery_metastore.py All tests/catalog/ tests now pass with strict ResourceWarning enforcement. Co-Authored-By: Claude Haiku 4.5 <[email protected]>
1 parent 08f6fb4 commit 5af30d5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎tests/catalog/test_base.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ def catalog(tmp_path: PosixPath) -> Generator[Catalog, None, None]:
3737

3838

3939
def test_load_catalog_in_memory() -> None:
40-
assert load_catalog("catalog", type="in-memory")
40+
catalog = load_catalog("catalog", type="in-memory")
41+
try:
42+
assert catalog
43+
finally:
44+
catalog.close()
4145

4246

4347
def test_load_catalog_impl_not_full_path() -> None:

0 commit comments

Comments
 (0)