diff --git a/bindings/python/tests/test_datafusion_table_provider.py b/bindings/python/tests/test_datafusion_table_provider.py index 53c7478efb..1edae0edf5 100644 --- a/bindings/python/tests/test_datafusion_table_provider.py +++ b/bindings/python/tests/test_datafusion_table_provider.py @@ -40,7 +40,7 @@ def warehouse(tmp_path_factory: pytest.TempPathFactory) -> Path: @pytest.fixture(scope="session") -def catalog(warehouse: Path) -> Catalog: +def catalog(warehouse: Path): catalog = load_catalog( "default", **{ @@ -48,7 +48,8 @@ def catalog(warehouse: Path) -> Catalog: "warehouse": f"file://{warehouse}", }, ) - return catalog + yield catalog + catalog.close() @pytest.fixture(scope="session") diff --git a/bindings/python/tests/test_huggingface_and_cdc.py b/bindings/python/tests/test_huggingface_and_cdc.py index 7e69ffe673..fe50fddfc2 100644 --- a/bindings/python/tests/test_huggingface_and_cdc.py +++ b/bindings/python/tests/test_huggingface_and_cdc.py @@ -47,13 +47,15 @@ @pytest.fixture(scope="module") def local_catalog(tmp_path_factory: pytest.TempPathFactory): warehouse = tmp_path_factory.mktemp("cdc_warehouse") - return load_catalog( + catalog = load_catalog( "default", **{ "uri": f"sqlite:///{warehouse}/pyiceberg_catalog.db", "warehouse": f"file://{warehouse}", }, ) + yield catalog + catalog.close() @pytest.fixture(scope="module") @@ -168,7 +170,8 @@ def hf_cdc_table(sample_table): # HfFileSystem.dircache may reflect the pre-write state; invalidate it so # subsequent reads (info/open) see the files just uploaded via xet. tbl.io.get_fs("hf").invalidate_cache() - return tbl, token + yield tbl, token + catalog.close() @requires_hf