Skip to content

Commit 3578104

Browse files
mroeschkejorisvandenbossche
authored andcommitted
CI/TST: Check for tzset in set_timezone (pandas-dev#59893)
* CI/TST: Check for tzset in set_timezone * adjust test message (cherry picked from commit b948821)
1 parent 7e16420 commit 3578104

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

pandas/_testing/contexts.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,15 @@ def set_timezone(tz: str) -> Generator[None, None, None]:
7878
import time
7979

8080
def setTZ(tz) -> None:
81-
if tz is None:
82-
try:
83-
del os.environ["TZ"]
84-
except KeyError:
85-
pass
86-
else:
87-
os.environ["TZ"] = tz
88-
time.tzset()
81+
if hasattr(time, "tzset"):
82+
if tz is None:
83+
try:
84+
del os.environ["TZ"]
85+
except KeyError:
86+
pass
87+
else:
88+
os.environ["TZ"] = tz
89+
time.tzset()
8990

9091
orig_tz = os.environ.get("TZ")
9192
setTZ(tz)

pandas/tests/tslibs/test_parsing.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@
3131
)
3232
def test_parsing_tzlocal_deprecated():
3333
# GH#50791
34-
msg = (
35-
"Parsing 'EST' as tzlocal.*"
36-
"Pass the 'tz' keyword or call tz_localize after construction instead"
34+
msg = "|".join(
35+
[
36+
r"Parsing 'EST' as tzlocal \(dependent on system timezone\) "
37+
r"is no longer supported\. "
38+
"Pass the 'tz' keyword or call tz_localize after construction instead",
39+
".*included an un-recognized timezone",
40+
]
3741
)
3842
dtstr = "Jan 15 2004 03:00 EST"
3943

0 commit comments

Comments
 (0)