From 35781045ae751ab53682b82d4f478f130d159aa9 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:47:10 -1000 Subject: [PATCH 1/4] CI/TST: Check for tzset in set_timezone (#59893) * CI/TST: Check for tzset in set_timezone * adjust test message (cherry picked from commit b9488218ae27b70d1669a932ab16e8ce5a257cf0) --- pandas/_testing/contexts.py | 17 +++++++++-------- pandas/tests/tslibs/test_parsing.py | 10 +++++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/pandas/_testing/contexts.py b/pandas/_testing/contexts.py index eb6e4a917889a..48616ee134582 100644 --- a/pandas/_testing/contexts.py +++ b/pandas/_testing/contexts.py @@ -78,14 +78,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) diff --git a/pandas/tests/tslibs/test_parsing.py b/pandas/tests/tslibs/test_parsing.py index d8f23156bd4d4..e528ad644032d 100644 --- a/pandas/tests/tslibs/test_parsing.py +++ b/pandas/tests/tslibs/test_parsing.py @@ -31,9 +31,13 @@ ) def test_parsing_tzlocal_deprecated(): # GH#50791 - msg = ( - "Parsing 'EST' as tzlocal.*" - "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" From 1e20ec9a48b20b0ee9e498c74bb269df6613d630 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Wed, 2 Oct 2024 15:44:37 +0200 Subject: [PATCH 2/4] keep warning message --- pandas/tests/tslibs/test_parsing.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pandas/tests/tslibs/test_parsing.py b/pandas/tests/tslibs/test_parsing.py index e528ad644032d..d8f23156bd4d4 100644 --- a/pandas/tests/tslibs/test_parsing.py +++ b/pandas/tests/tslibs/test_parsing.py @@ -31,13 +31,9 @@ ) def test_parsing_tzlocal_deprecated(): # GH#50791 - 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", - ] + msg = ( + "Parsing 'EST' as tzlocal.*" + "Pass the 'tz' keyword or call tz_localize after construction instead" ) dtstr = "Jan 15 2004 03:00 EST" From aa5aad857b79a7775928ec942ec1a691c4fb6e12 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Wed, 2 Oct 2024 21:33:09 +0200 Subject: [PATCH 3/4] catch broader warning message --- pandas/tests/tslibs/test_parsing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/tslibs/test_parsing.py b/pandas/tests/tslibs/test_parsing.py index d8f23156bd4d4..2a965610ff0dc 100644 --- a/pandas/tests/tslibs/test_parsing.py +++ b/pandas/tests/tslibs/test_parsing.py @@ -34,6 +34,7 @@ def test_parsing_tzlocal_deprecated(): msg = ( "Parsing 'EST' as tzlocal.*" "Pass the 'tz' keyword or call tz_localize after construction instead" + "|Parsed string" ) dtstr = "Jan 15 2004 03:00 EST" From 679100a4b081f90ddb58044897bc33a40d63021d Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Wed, 2 Oct 2024 22:07:58 +0200 Subject: [PATCH 4/4] skip test on arm --- pandas/tests/tslibs/test_parsing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/tslibs/test_parsing.py b/pandas/tests/tslibs/test_parsing.py index 2a965610ff0dc..fb05a57056a83 100644 --- a/pandas/tests/tslibs/test_parsing.py +++ b/pandas/tests/tslibs/test_parsing.py @@ -17,6 +17,7 @@ from pandas._libs.tslibs.parsing import parse_datetime_string_with_reso from pandas.compat import ( ISMUSL, + is_platform_arm, is_platform_windows, ) import pandas.util._test_decorators as td @@ -26,7 +27,7 @@ @pytest.mark.skipif( - is_platform_windows() or ISMUSL, + is_platform_windows() or ISMUSL or is_platform_arm(), reason="TZ setting incorrect on Windows and MUSL Linux", ) def test_parsing_tzlocal_deprecated(): @@ -34,7 +35,6 @@ def test_parsing_tzlocal_deprecated(): msg = ( "Parsing 'EST' as tzlocal.*" "Pass the 'tz' keyword or call tz_localize after construction instead" - "|Parsed string" ) dtstr = "Jan 15 2004 03:00 EST"