1
1
import pytest
2
2
3
+ import pytz
4
+ import dateutil
3
5
import numpy as np
4
6
5
7
from datetime import datetime
8
+ from dateutil .tz import tzlocal
9
+
6
10
import pandas as pd
7
11
import pandas .util .testing as tm
8
12
from pandas import (DatetimeIndex , date_range , Series , NaT , Index , Timestamp ,
@@ -124,8 +128,6 @@ def test_astype_raises(self):
124
128
pytest .raises (ValueError , idx .astype , 'datetime64[D]' )
125
129
126
130
def test_index_convert_to_datetime_array (self ):
127
- pytest .importorskip ("pytz" )
128
-
129
131
def _check_rng (rng ):
130
132
converted = rng .to_pydatetime ()
131
133
assert isinstance (converted , np .ndarray )
@@ -143,8 +145,6 @@ def _check_rng(rng):
143
145
_check_rng (rng_utc )
144
146
145
147
def test_index_convert_to_datetime_array_explicit_pytz (self ):
146
- pytz = pytest .importorskip ("pytz" )
147
-
148
148
def _check_rng (rng ):
149
149
converted = rng .to_pydatetime ()
150
150
assert isinstance (converted , np .ndarray )
@@ -163,8 +163,6 @@ def _check_rng(rng):
163
163
_check_rng (rng_utc )
164
164
165
165
def test_index_convert_to_datetime_array_dateutil (self ):
166
- dateutil = pytest .importorskip ("dateutil" )
167
-
168
166
def _check_rng (rng ):
169
167
converted = rng .to_pydatetime ()
170
168
assert isinstance (converted , np .ndarray )
@@ -207,8 +205,6 @@ def test_to_period_microsecond(self):
207
205
assert period [1 ] == Period ('2007-01-01 10:11:13.789123Z' , 'U' )
208
206
209
207
def test_to_period_tz_pytz (self ):
210
- pytest .importorskip ("pytz" )
211
- from dateutil .tz import tzlocal
212
208
from pytz import utc as UTC
213
209
214
210
xp = date_range ('1/1/2000' , '4/1/2000' ).to_period ()
@@ -238,9 +234,6 @@ def test_to_period_tz_pytz(self):
238
234
tm .assert_index_equal (ts .to_period (), xp )
239
235
240
236
def test_to_period_tz_explicit_pytz (self ):
241
- pytz = pytest .importorskip ("pytz" )
242
- from dateutil .tz import tzlocal
243
-
244
237
xp = date_range ('1/1/2000' , '4/1/2000' ).to_period ()
245
238
246
239
ts = date_range ('1/1/2000' , '4/1/2000' , tz = pytz .timezone ('US/Eastern' ))
@@ -268,9 +261,6 @@ def test_to_period_tz_explicit_pytz(self):
268
261
tm .assert_index_equal (ts .to_period (), xp )
269
262
270
263
def test_to_period_tz_dateutil (self ):
271
- dateutil = pytest .importorskip ("dateutil" )
272
- from dateutil .tz import tzlocal
273
-
274
264
xp = date_range ('1/1/2000' , '4/1/2000' ).to_period ()
275
265
276
266
ts = date_range ('1/1/2000' , '4/1/2000' , tz = 'dateutil/US/Eastern' )
0 commit comments