88from dateutil .parser import parse
99
1010import pandas .util ._test_decorators as td
11- from pandas .conftest import is_dateutil_le_261 , is_dateutil_gt_261
1211from pandas import compat
1312from pandas .util import testing as tm
1413from pandas ._libs .tslibs import parsing
@@ -96,7 +95,7 @@ def test_parsers_monthfreq(self):
9695class TestGuessDatetimeFormat (object ):
9796
9897 @td .skip_if_not_us_locale
99- @is_dateutil_le_261
98+ @td . skip_if_dateutil_le_261
10099 @pytest .mark .parametrize (
101100 "string, format" ,
102101 [
@@ -113,7 +112,7 @@ def test_guess_datetime_format_with_parseable_formats(
113112 assert result == format
114113
115114 @td .skip_if_not_us_locale
116- @is_dateutil_gt_261
115+ @td . skip_if_dateutil_gt_261
117116 @pytest .mark .parametrize (
118117 "string" ,
119118 ['20111230' , '2011-12-30' , '30-12-2011' ,
@@ -124,7 +123,7 @@ def test_guess_datetime_format_with_parseable_formats_gt_261(
124123 result = parsing ._guess_datetime_format (string )
125124 assert result is None
126125
127- @is_dateutil_le_261
126+ @td . skip_if_dateutil_le_261
128127 @pytest .mark .parametrize (
129128 "dayfirst, expected" ,
130129 [
@@ -136,17 +135,22 @@ def test_guess_datetime_format_with_dayfirst(self, dayfirst, expected):
136135 ambiguous_string , dayfirst = dayfirst )
137136 assert result == expected
138137
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 ):
143140 ambiguous_string = '01/01/2011'
144141 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'
147151
148152 @td .skip_if_has_locale
149- @is_dateutil_le_261
153+ @td . skip_if_dateutil_le_261
150154 @pytest .mark .parametrize (
151155 "string, format" ,
152156 [
@@ -158,19 +162,6 @@ def test_guess_datetime_format_with_locale_specific_formats(
158162 result = parsing ._guess_datetime_format (string )
159163 assert result == format
160164
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-
174165 def test_guess_datetime_format_invalid_inputs (self ):
175166 # A datetime string must include a year, month and a day for it
176167 # to be guessable, in addition to being a string that looks like
@@ -189,7 +180,7 @@ def test_guess_datetime_format_invalid_inputs(self):
189180 for invalid_dt in invalid_dts :
190181 assert parsing ._guess_datetime_format (invalid_dt ) is None
191182
192- @is_dateutil_le_261
183+ @td . skip_if_dateutil_le_261
193184 @pytest .mark .parametrize (
194185 "string, format" ,
195186 [
@@ -204,21 +195,6 @@ def test_guess_datetime_format_nopadding(self, string, format):
204195 result = parsing ._guess_datetime_format (string )
205196 assert result == format
206197
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-
222198
223199class TestArrayToDatetime (object ):
224200 def test_try_parse_dates (self ):
0 commit comments