Skip to content

Commit d08bc10

Browse files
Use td.check_file_leaks() in a way that works in combination with tm.ensure_clean
1 parent 8fa751e commit d08bc10

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

pandas/tests/io/parser/test_common.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -2082,18 +2082,14 @@ def test_integer_precision(all_parsers):
20822082
tm.assert_series_equal(result, expected)
20832083

20842084

2085-
@td.skip_if_no("psutil")
20862085
def test_file_descriptor_leak(all_parsers):
20872086
# GH 31488
2088-
# Please note that using tm.ensure_clean does not work in combination
2089-
# with td.check_file_leaks as tm.ensure_clean closes the file
2090-
# thereby preventing the leak check to trigger
2091-
import psutil
20922087

2093-
proc = psutil.Process()
20942088
parser = all_parsers
20952089
with tm.ensure_clean() as path:
2096-
expected = proc.open_files()
2097-
with pytest.raises(EmptyDataError, match="No columns to parse from file"):
2098-
parser.read_csv(path)
2099-
assert proc.open_files() == expected
2090+
2091+
def test():
2092+
with pytest.raises(EmptyDataError, match="No columns to parse from file"):
2093+
parser.read_csv(path)
2094+
2095+
td.check_file_leaks(test)()

0 commit comments

Comments
 (0)