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..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():