Skip to content

Commit f555e51

Browse files
fix: close leaked InMemoryCatalog in test_pyarrow.py catalog fixture
Fixes ResourceWarning unclosed database connections in test_pyarrow.py tests. The local catalog fixture (line 1508-1510) shadowed the global properly-closing fixture from conftest.py. It returned the InMemoryCatalog without yielding or calling close(), leaving SQLite connections uncovered. This fixture is used by 6 tests in the file (8 instances total including parametrized variants): - test_identity_transform_column_projection - test_identity_transform_column_projection_with_falsy_value (3 parametrized) - test_identity_transform_columns_projection - test_inspect_partition_for_nested_field - test_inspect_partitions_respects_partition_evolution - test_partition_column_projection_with_schema_evolution Changed the fixture to a generator that yields and closes the catalog on teardown, matching the pattern established in conftest.py and elsewhere on this branch for issue apache#2530. All 8 affected tests now pass without ResourceWarnings. Co-Authored-By: Claude Haiku 4.5 <[email protected]>
1 parent 6b110a7 commit f555e51

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎tests/io/test_pyarrow.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,8 +1506,10 @@ def test_identity_transform_columns_projection(tmp_path: str, catalog: InMemoryC
15061506

15071507

15081508
@pytest.fixture
1509-
def catalog() -> InMemoryCatalog:
1510-
return InMemoryCatalog("test.in_memory.catalog", **{"test.key": "test.value"})
1509+
def catalog() -> Iterator[InMemoryCatalog]:
1510+
cat = InMemoryCatalog("test.in_memory.catalog", **{"test.key": "test.value"})
1511+
yield cat
1512+
cat.close()
15111513

15121514

15131515
def test_projection_filter(schema_int: Schema, file_int: str) -> None:

0 commit comments

Comments
 (0)