Skip to content

Commit 20d352c

Browse files
fix: close leaked InMemoryCatalog in test_inspect.py catalog fixture
Fixes ResourceWarning unclosed database connections in test_inspect.py tests. The local catalog fixture (lines 38-42) returned the InMemoryCatalog without yielding or calling close(), leaving SQLite connections uncovered. 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 #2530. All 4 tests in test_inspect.py now pass without ResourceWarnings. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent f555e51 commit 20d352c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tests/table/test_inspect.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
from collections.abc import Iterator
1819
from pathlib import PosixPath
1920

2021
import pyarrow as pa
@@ -36,10 +37,11 @@ def test_readable_bound_without_bound() -> None:
3637

3738

3839
@pytest.fixture
39-
def catalog(tmp_path: PosixPath) -> InMemoryCatalog:
40+
def catalog(tmp_path: PosixPath) -> Iterator[InMemoryCatalog]:
4041
cat = InMemoryCatalog("test.in_memory.catalog", warehouse=tmp_path.absolute().as_posix())
4142
cat.create_namespace("default")
42-
return cat
43+
yield cat
44+
cat.close()
4345

4446

4547
def test_inspect_entries_and_files_render_empty_string_bound(catalog: InMemoryCatalog) -> None:

0 commit comments

Comments
 (0)