From a64a31b92a403be4a7079e7f2f080b84d5c2d39e Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:11:58 -0700 Subject: [PATCH 1/2] CI/TST: Check for tzset in set_timezone --- pandas/_testing/contexts.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pandas/_testing/contexts.py b/pandas/_testing/contexts.py index 91b5d2a981bef..4ca67d6fc082d 100644 --- a/pandas/_testing/contexts.py +++ b/pandas/_testing/contexts.py @@ -73,14 +73,15 @@ def set_timezone(tz: str) -> Generator[None, None, None]: import time def setTZ(tz) -> None: - if tz is None: - try: - del os.environ["TZ"] - except KeyError: - pass - else: - os.environ["TZ"] = tz - time.tzset() + if hasattr(time, "tzset"): + if tz is None: + try: + del os.environ["TZ"] + except KeyError: + pass + else: + os.environ["TZ"] = tz + time.tzset() orig_tz = os.environ.get("TZ") setTZ(tz) From 328d5da6c08ff3f1326676dfd95940be7a93f24a Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:54:08 -0700 Subject: [PATCH 2/2] adjust test message --- pandas/tests/tslibs/test_parsing.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pandas/tests/tslibs/test_parsing.py b/pandas/tests/tslibs/test_parsing.py index 9b64beaf09273..07425af8ed37a 100644 --- a/pandas/tests/tslibs/test_parsing.py +++ b/pandas/tests/tslibs/test_parsing.py @@ -37,10 +37,13 @@ ) def test_parsing_tzlocal_deprecated(): # GH#50791 - msg = ( - r"Parsing 'EST' as tzlocal \(dependent on system timezone\) " - r"is no longer supported\. " - "Pass the 'tz' keyword or call tz_localize after construction instead" + msg = "|".join( + [ + r"Parsing 'EST' as tzlocal \(dependent on system timezone\) " + r"is no longer supported\. " + "Pass the 'tz' keyword or call tz_localize after construction instead", + ".*included an un-recognized timezone", + ] ) dtstr = "Jan 15 2004 03:00 EST"