Skip to content

Commit

Permalink
CI/TST: Check for tzset in set_timezone (pandas-dev#59893)
Browse files Browse the repository at this point in the history
* CI/TST: Check for tzset in set_timezone

* adjust test message
  • Loading branch information
mroeschke authored Sep 26, 2024
1 parent b96491a commit b948821
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
17 changes: 9 additions & 8 deletions pandas/_testing/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,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
11 changes: 7 additions & 4 deletions pandas/tests/tslibs/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@
)
def test_parsing_tzlocal_deprecated():
# GH#50791
msg = (
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"
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"

Expand Down

0 comments on commit b948821

Please sign in to comment.