Skip to content

Commit b948821

Browse files
authored
CI/TST: Check for tzset in set_timezone (pandas-dev#59893)
* CI/TST: Check for tzset in set_timezone * adjust test message
1 parent b96491a commit b948821

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

pandas/_testing/contexts.py

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

7575
def setTZ(tz) -> None:
76-
if tz is None:
77-
try:
78-
del os.environ["TZ"]
79-
except KeyError:
80-
pass
81-
else:
82-
os.environ["TZ"] = tz
83-
time.tzset()
76+
if hasattr(time, "tzset"):
77+
if tz is None:
78+
try:
79+
del os.environ["TZ"]
80+
except KeyError:
81+
pass
82+
else:
83+
os.environ["TZ"] = tz
84+
time.tzset()
8485

8586
orig_tz = os.environ.get("TZ")
8687
setTZ(tz)

pandas/tests/tslibs/test_parsing.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@
3737
)
3838
def test_parsing_tzlocal_deprecated():
3939
# GH#50791
40-
msg = (
41-
r"Parsing 'EST' as tzlocal \(dependent on system timezone\) "
42-
r"is no longer supported\. "
43-
"Pass the 'tz' keyword or call tz_localize after construction instead"
40+
msg = "|".join(
41+
[
42+
r"Parsing 'EST' as tzlocal \(dependent on system timezone\) "
43+
r"is no longer supported\. "
44+
"Pass the 'tz' keyword or call tz_localize after construction instead",
45+
".*included an un-recognized timezone",
46+
]
4447
)
4548
dtstr = "Jan 15 2004 03:00 EST"
4649

0 commit comments

Comments
 (0)