Skip to content

Commit

Permalink
Backport PR #59893 (CI/TST: Check for tzset in set_timezone) (#59941)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
  • Loading branch information
jorisvandenbossche and mroeschke authored Oct 3, 2024
1 parent 24510bd commit 6e5ccd8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 9 additions & 8 deletions pandas/_testing/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/tslibs/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand Down

0 comments on commit 6e5ccd8

Please sign in to comment.