From 22d23f34255c0fb6a3d2ce764dbb1685c8f5b710 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 22 Nov 2023 08:13:26 -1000 Subject: [PATCH] Backport PR #56109: CI: Ignore EncodingWarning in assert_produces_warning --- pandas/_testing/_warnings.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandas/_testing/_warnings.py b/pandas/_testing/_warnings.py index 11cf60ef36a9c..c1c70605d9648 100644 --- a/pandas/_testing/_warnings.py +++ b/pandas/_testing/_warnings.py @@ -13,6 +13,8 @@ ) import warnings +from pandas.compat import PY311 + if TYPE_CHECKING: from collections.abc import ( Generator, @@ -179,6 +181,11 @@ def _assert_caught_no_extra_warnings( # due to these open files. if any("matplotlib" in mod for mod in sys.modules): continue + if PY311 and actual_warning.category == EncodingWarning: + # EncodingWarnings are checked in the CI + # pyproject.toml errors on EncodingWarnings in pandas + # Ignore EncodingWarnings from other libraries + continue extra_warnings.append( ( actual_warning.category.__name__,