diff --git a/pandas/conftest.py b/pandas/conftest.py index 97cc514e31bb3..8d3c9d4dac400 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -1181,7 +1181,13 @@ def ip(): pytest.importorskip("IPython", minversion="6.0.0") from IPython.core.interactiveshell import InteractiveShell - return InteractiveShell() + # GH#35711 make sure sqlite history file handle is not leaked + from traitlets.config import Config + + c = Config() + c.HistoryManager.hist_file = ":memory:" + + return InteractiveShell(config=c) @pytest.fixture(params=["bsr", "coo", "csc", "csr", "dia", "dok", "lil"]) diff --git a/pandas/tests/io/conftest.py b/pandas/tests/io/conftest.py index fcee25c258efa..39b9a1cd4fa28 100644 --- a/pandas/tests/io/conftest.py +++ b/pandas/tests/io/conftest.py @@ -2,11 +2,22 @@ import pytest +import pandas.util._test_decorators as td + import pandas._testing as tm from pandas.io.parsers import read_csv +@pytest.fixture(autouse=True) +def check_file_leaks(): + """ + Check that a test does not leak file handles. + """ + with td.file_leak_context(): + yield + + @pytest.fixture def tips_file(datapath): """Path to the tips dataset""" diff --git a/pandas/tests/io/excel/test_readers.py b/pandas/tests/io/excel/test_readers.py index 51fbbf836a03f..49415a7e0a126 100644 --- a/pandas/tests/io/excel/test_readers.py +++ b/pandas/tests/io/excel/test_readers.py @@ -650,7 +650,6 @@ def test_read_from_pathlib_path(self, read_ext): tm.assert_frame_equal(expected, actual) @td.skip_if_no("py.path") - @td.check_file_leaks def test_read_from_py_localpath(self, read_ext): # GH12655 @@ -664,7 +663,6 @@ def test_read_from_py_localpath(self, read_ext): tm.assert_frame_equal(expected, actual) - @td.check_file_leaks def test_close_from_py_localpath(self, read_ext): # GH31467