8
8
from dateutil .parser import parse
9
9
10
10
import pandas .util ._test_decorators as td
11
- from pandas .conftest import is_dateutil_le_261 , is_dateutil_gt_261
12
11
from pandas import compat
13
12
from pandas .util import testing as tm
14
13
from pandas ._libs .tslibs import parsing
@@ -96,7 +95,7 @@ def test_parsers_monthfreq(self):
96
95
class TestGuessDatetimeFormat (object ):
97
96
98
97
@td .skip_if_not_us_locale
99
- @is_dateutil_le_261
98
+ @td . skip_if_dateutil_le_261
100
99
@pytest .mark .parametrize (
101
100
"string, format" ,
102
101
[
@@ -113,7 +112,7 @@ def test_guess_datetime_format_with_parseable_formats(
113
112
assert result == format
114
113
115
114
@td .skip_if_not_us_locale
116
- @is_dateutil_gt_261
115
+ @td . skip_if_dateutil_gt_261
117
116
@pytest .mark .parametrize (
118
117
"string" ,
119
118
['20111230' , '2011-12-30' , '30-12-2011' ,
@@ -124,7 +123,7 @@ def test_guess_datetime_format_with_parseable_formats_gt_261(
124
123
result = parsing ._guess_datetime_format (string )
125
124
assert result is None
126
125
127
- @is_dateutil_le_261
126
+ @td . skip_if_dateutil_le_261
128
127
@pytest .mark .parametrize (
129
128
"dayfirst, expected" ,
130
129
[
@@ -136,17 +135,22 @@ def test_guess_datetime_format_with_dayfirst(self, dayfirst, expected):
136
135
ambiguous_string , dayfirst = dayfirst )
137
136
assert result == expected
138
137
139
- @is_dateutil_gt_261
140
- @pytest .mark .parametrize (
141
- "dayfirst" , [True , False ])
142
- def test_guess_datetime_format_with_dayfirst_gt_261 (self , dayfirst ):
138
+ @td .skip_if_dateutil_gt_261
139
+ def test_guess_datetime_format_with_dayfirst_gt_261 (self ):
143
140
ambiguous_string = '01/01/2011'
144
141
result = parsing ._guess_datetime_format (
145
- ambiguous_string , dayfirst = dayfirst )
146
- assert result is None
142
+ ambiguous_string , dayfirst = True )
143
+ assert result == '%d/%m/%Y'
144
+
145
+ @td .skip_if_dateutil_gt_261
146
+ def test_guess_datetime_format_no_dayfirst_gt_261 (self ):
147
+ ambiguous_string = '01/01/2011'
148
+ result = parsing ._guess_datetime_format (
149
+ ambiguous_string , dayfirst = False )
150
+ assert result == '%m/%d/%Y'
147
151
148
152
@td .skip_if_has_locale
149
- @is_dateutil_le_261
153
+ @td . skip_if_dateutil_le_261
150
154
@pytest .mark .parametrize (
151
155
"string, format" ,
152
156
[
@@ -158,19 +162,6 @@ def test_guess_datetime_format_with_locale_specific_formats(
158
162
result = parsing ._guess_datetime_format (string )
159
163
assert result == format
160
164
161
- @td .skip_if_has_locale
162
- @is_dateutil_gt_261
163
- @pytest .mark .parametrize (
164
- "string" ,
165
- [
166
- '30/Dec/2011' ,
167
- '30/December/2011' ,
168
- '30/Dec/2011 00:00:00' ])
169
- def test_guess_datetime_format_with_locale_specific_formats_gt_261 (
170
- self , string ):
171
- result = parsing ._guess_datetime_format (string )
172
- assert result is None
173
-
174
165
def test_guess_datetime_format_invalid_inputs (self ):
175
166
# A datetime string must include a year, month and a day for it
176
167
# to be guessable, in addition to being a string that looks like
@@ -189,7 +180,7 @@ def test_guess_datetime_format_invalid_inputs(self):
189
180
for invalid_dt in invalid_dts :
190
181
assert parsing ._guess_datetime_format (invalid_dt ) is None
191
182
192
- @is_dateutil_le_261
183
+ @td . skip_if_dateutil_le_261
193
184
@pytest .mark .parametrize (
194
185
"string, format" ,
195
186
[
@@ -204,21 +195,6 @@ def test_guess_datetime_format_nopadding(self, string, format):
204
195
result = parsing ._guess_datetime_format (string )
205
196
assert result == format
206
197
207
- @is_dateutil_gt_261
208
- @pytest .mark .parametrize (
209
- "string" ,
210
- [
211
- '2011-1-1' ,
212
- '30-1-2011' ,
213
- '1/1/2011' ,
214
- '2011-1-1 00:00:00' ,
215
- '2011-1-1 0:0:0' ,
216
- '2011-1-3T00:00:0' ])
217
- def test_guess_datetime_format_nopadding_gt_261 (self , string ):
218
- # GH 11142
219
- result = parsing ._guess_datetime_format (string )
220
- assert result is None
221
-
222
198
223
199
class TestArrayToDatetime (object ):
224
200
def test_try_parse_dates (self ):
0 commit comments