Skip to content

Commit d2108a5

Browse files
Backport PR #45204: CI: Use broader condition to maybe catch ResourceWarning from Matplotlib (#45504)
Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 6bbf454 commit d2108a5

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

pandas/_testing/_warnings.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from contextlib import contextmanager
44
import re
5-
import subprocess
5+
import sys
66
from typing import (
77
Sequence,
88
Type,
@@ -159,15 +159,9 @@ def _assert_caught_no_extra_warnings(
159159
if any(msg in str(actual_warning.message) for msg in unclosed_ssl):
160160
continue
161161
# GH 44844: Matplotlib leaves font files open during the entire process
162-
# Don't make CI flaky if ResourceWarning raised due to these open files.
163-
try:
164-
lsof = subprocess.check_output(
165-
["lsof", "-d", "0-25", "-F", "n"]
166-
).decode("utf-8")
167-
except (subprocess.CalledProcessError, FileNotFoundError):
168-
# FileNotFoundError for Windows
169-
lsof = ""
170-
if re.search(r"\.ttf|\.ttc|\.otf", lsof):
162+
# upon import. Don't make CI flaky if ResourceWarning raised
163+
# due to these open files.
164+
if any("matplotlib" in mod for mod in sys.modules):
171165
continue
172166

173167
extra_warnings.append(

0 commit comments

Comments
 (0)