Skip to content

Commit 4e3940f

Browse files
authored
CI: avoid file leak from ipython tests (#35836)
1 parent 0e199f3 commit 4e3940f

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

pandas/conftest.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,13 @@ def ip():
11811181
pytest.importorskip("IPython", minversion="6.0.0")
11821182
from IPython.core.interactiveshell import InteractiveShell
11831183

1184-
return InteractiveShell()
1184+
# GH#35711 make sure sqlite history file handle is not leaked
1185+
from traitlets.config import Config # noqa: F401 isort:skip
1186+
1187+
c = Config()
1188+
c.HistoryManager.hist_file = ":memory:"
1189+
1190+
return InteractiveShell(config=c)
11851191

11861192

11871193
@pytest.fixture(params=["bsr", "coo", "csc", "csr", "dia", "dok", "lil"])

pandas/tests/frame/test_api.py

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import numpy as np
77
import pytest
88

9+
import pandas.util._test_decorators as td
910
from pandas.util._test_decorators import async_mark, skip_if_no
1011

1112
import pandas as pd
@@ -521,6 +522,7 @@ def _check_f(base, f):
521522
_check_f(d.copy(), f)
522523

523524
@async_mark()
525+
@td.check_file_leaks
524526
async def test_tab_complete_warning(self, ip):
525527
# GH 16409
526528
pytest.importorskip("IPython", minversion="6.0.0")

pandas/tests/io/formats/test_format.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import pytz
2020

2121
from pandas.compat import is_platform_32bit, is_platform_windows
22+
import pandas.util._test_decorators as td
2223

2324
import pandas as pd
2425
from pandas import (
@@ -3338,6 +3339,7 @@ def test_format_percentiles_integer_idx():
33383339
assert result == expected
33393340

33403341

3342+
@td.check_file_leaks
33413343
def test_repr_html_ipython_config(ip):
33423344
code = textwrap.dedent(
33433345
"""\

pandas/tests/resample/test_resampler_grouper.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import numpy as np
44
import pytest
55

6+
import pandas.util._test_decorators as td
67
from pandas.util._test_decorators import async_mark
78

89
import pandas as pd
@@ -17,6 +18,7 @@
1718

1819

1920
@async_mark()
21+
@td.check_file_leaks
2022
async def test_tab_complete_ipython6_warning(ip):
2123
from IPython.core.completer import provisionalcompleter
2224

pandas/tests/series/test_api.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import numpy as np
66
import pytest
77

8+
import pandas.util._test_decorators as td
89
from pandas.util._test_decorators import async_mark
910

1011
import pandas as pd
@@ -486,6 +487,7 @@ def test_empty_method(self):
486487
assert not full_series.empty
487488

488489
@async_mark()
490+
@td.check_file_leaks
489491
async def test_tab_complete_warning(self, ip):
490492
# https://github.com/pandas-dev/pandas/issues/16409
491493
pytest.importorskip("IPython", minversion="6.0.0")

0 commit comments

Comments
 (0)