File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 33 timedelta ,
44 timezone ,
55)
6+ import subprocess
7+ import sys
8+ import textwrap
69
710import dateutil .tz
811import pytest
1619from pandas import Timestamp
1720
1821
22+ def test_no_timezone_data ():
23+ # https://github.com/pandas-dev/pandas/pull/63335
24+ # Test error message when timezone data is not available.
25+ msg = "'No time zone found with key Europe/Brussels'"
26+ code = textwrap .dedent (
27+ f"""\
28+ import sys, zoneinfo, pandas as pd
29+ sys.modules['tzdata'] = None
30+ zoneinfo.reset_tzpath(['/path/to/nowhere'])
31+ try:
32+ pd.to_datetime('2012-01-01').tz_localize('Europe/Brussels')
33+ except zoneinfo.ZoneInfoNotFoundError as err:
34+ assert str(err) == "{ msg } "
35+ """
36+ )
37+ subprocess .check_call ([sys .executable , "-c" , code ])
38+
39+
1940def test_is_utc (utc_fixture ):
2041 tz = timezones .maybe_get_tz (utc_fixture )
2142 assert timezones .is_utc (tz )
You can’t perform that action at this time.
0 commit comments