Skip to content

Commit

Permalink
Run GC in file leak check (#48294)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonashaag authored Aug 31, 2022
1 parent baf1d2c commit e7414aa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pandas/util/_test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_foo():
from __future__ import annotations

from contextlib import contextmanager
import gc
import locale
from typing import (
Callable,
Expand Down Expand Up @@ -272,12 +273,13 @@ def file_leak_context() -> Iterator[None]:
try:
yield
finally:
gc.collect()
flist2 = proc.open_files()
# on some builds open_files includes file position, which we _dont_
# expect to remain unchanged, so we need to compare excluding that
flist_ex = [(x.path, x.fd) for x in flist]
flist2_ex = [(x.path, x.fd) for x in flist2]
assert flist2_ex == flist_ex, (flist2, flist)
assert set(flist2_ex) <= set(flist_ex), (flist2, flist)

conns2 = proc.connections()
assert conns2 == conns, (conns2, conns)
Expand Down

0 comments on commit e7414aa

Please sign in to comment.