1
1
import datetime
2
2
import pickle
3
+ from zoneinfo import ZoneInfo
3
4
4
5
import pytest
5
6
16
17
suppress_warnings ,
17
18
)
18
19
19
- # Use pytz to test out various time zones if available
20
- try :
21
- from pytz import timezone as tz
22
- _has_pytz = True
23
- except ImportError :
24
- _has_pytz = False
25
-
26
20
try :
27
21
RecursionError
28
22
except NameError :
@@ -1886,7 +1880,6 @@ def test_datetime_as_string(self):
1886
1880
np .datetime64 ('2032-01-01T00:00:00' , 'us' ), unit = 'auto' ),
1887
1881
'2032-01-01' )
1888
1882
1889
- @pytest .mark .skipif (not _has_pytz , reason = "The pytz module is not available." )
1890
1883
def test_datetime_as_string_timezone (self ):
1891
1884
# timezone='local' vs 'UTC'
1892
1885
a = np .datetime64 ('2010-03-15T06:30' , 'm' )
@@ -1901,29 +1894,29 @@ def test_datetime_as_string_timezone(self):
1901
1894
1902
1895
b = np .datetime64 ('2010-02-15T06:30' , 'm' )
1903
1896
1904
- assert_equal (np .datetime_as_string (a , timezone = tz ('US/Central' )),
1897
+ assert_equal (np .datetime_as_string (a , timezone = ZoneInfo ('US/Central' )),
1905
1898
'2010-03-15T01:30-0500' )
1906
- assert_equal (np .datetime_as_string (a , timezone = tz ('US/Eastern' )),
1899
+ assert_equal (np .datetime_as_string (a , timezone = ZoneInfo ('US/Eastern' )),
1907
1900
'2010-03-15T02:30-0400' )
1908
- assert_equal (np .datetime_as_string (a , timezone = tz ('US/Pacific' )),
1901
+ assert_equal (np .datetime_as_string (a , timezone = ZoneInfo ('US/Pacific' )),
1909
1902
'2010-03-14T23:30-0700' )
1910
1903
1911
- assert_equal (np .datetime_as_string (b , timezone = tz ('US/Central' )),
1904
+ assert_equal (np .datetime_as_string (b , timezone = ZoneInfo ('US/Central' )),
1912
1905
'2010-02-15T00:30-0600' )
1913
- assert_equal (np .datetime_as_string (b , timezone = tz ('US/Eastern' )),
1906
+ assert_equal (np .datetime_as_string (b , timezone = ZoneInfo ('US/Eastern' )),
1914
1907
'2010-02-15T01:30-0500' )
1915
- assert_equal (np .datetime_as_string (b , timezone = tz ('US/Pacific' )),
1908
+ assert_equal (np .datetime_as_string (b , timezone = ZoneInfo ('US/Pacific' )),
1916
1909
'2010-02-14T22:30-0800' )
1917
1910
1918
1911
# Dates to strings with a timezone attached is disabled by default
1919
1912
assert_raises (TypeError , np .datetime_as_string , a , unit = 'D' ,
1920
- timezone = tz ('US/Pacific' ))
1913
+ timezone = ZoneInfo ('US/Pacific' ))
1921
1914
# Check that we can print out the date in the specified time zone
1922
1915
assert_equal (np .datetime_as_string (a , unit = 'D' ,
1923
- timezone = tz ('US/Pacific' ), casting = 'unsafe' ),
1916
+ timezone = ZoneInfo ('US/Pacific' ), casting = 'unsafe' ),
1924
1917
'2010-03-14' )
1925
1918
assert_equal (np .datetime_as_string (b , unit = 'D' ,
1926
- timezone = tz ('US/Central' ), casting = 'unsafe' ),
1919
+ timezone = ZoneInfo ('US/Central' ), casting = 'unsafe' ),
1927
1920
'2010-02-15' )
1928
1921
1929
1922
def test_datetime_arange (self ):
0 commit comments