Skip to content

Commit e7414aa

Browse files
authored
Run GC in file leak check (#48294)
1 parent baf1d2c commit e7414aa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pandas/util/_test_decorators.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def test_foo():
2626
from __future__ import annotations
2727

2828
from contextlib import contextmanager
29+
import gc
2930
import locale
3031
from typing import (
3132
Callable,
@@ -272,12 +273,13 @@ def file_leak_context() -> Iterator[None]:
272273
try:
273274
yield
274275
finally:
276+
gc.collect()
275277
flist2 = proc.open_files()
276278
# on some builds open_files includes file position, which we _dont_
277279
# expect to remain unchanged, so we need to compare excluding that
278280
flist_ex = [(x.path, x.fd) for x in flist]
279281
flist2_ex = [(x.path, x.fd) for x in flist2]
280-
assert flist2_ex == flist_ex, (flist2, flist)
282+
assert set(flist2_ex) <= set(flist_ex), (flist2, flist)
281283

282284
conns2 = proc.connections()
283285
assert conns2 == conns, (conns2, conns)

0 commit comments

Comments
 (0)