@@ -67,37 +67,52 @@ def test_parsers_monthfreq(self):
67
67
68
68
69
69
class TestGuessDatetimeFormat (object ):
70
- def test_guess_datetime_format_with_parseable_formats (self ):
70
+
71
+ @pytest .mark .xfail (reason = "GH18141 - dateutil > 2.6.1 broken" )
72
+ @pytest .mark .parametrize (
73
+ "string, format" ,
74
+ [
75
+ ('20111230' , '%Y%m%d' ),
76
+ ('2011-12-30' , '%Y-%m-%d' ),
77
+ ('30-12-2011' , '%d-%m-%Y' ),
78
+ ('2011-12-30 00:00:00' , '%Y-%m-%d %H:%M:%S' ),
79
+ ('2011-12-30T00:00:00' , '%Y-%m-%dT%H:%M:%S' ),
80
+ ('2011-12-30 00:00:00.000000' ,
81
+ '%Y-%m-%d %H:%M:%S.%f' )])
82
+ def test_guess_datetime_format_with_parseable_formats (
83
+ self , string , format ):
71
84
tm ._skip_if_not_us_locale ()
72
- dt_string_to_format = (('20111230' , '%Y%m%d' ),
73
- ('2011-12-30' , '%Y-%m-%d' ),
74
- ('30-12-2011' , '%d-%m-%Y' ),
75
- ('2011-12-30 00:00:00' , '%Y-%m-%d %H:%M:%S' ),
76
- ('2011-12-30T00:00:00' , '%Y-%m-%dT%H:%M:%S' ),
77
- ('2011-12-30 00:00:00.000000' ,
78
- '%Y-%m-%d %H:%M:%S.%f' ), )
79
-
80
- for dt_string , dt_format in dt_string_to_format :
81
- assert parsing ._guess_datetime_format (dt_string ) == dt_format
82
-
83
- def test_guess_datetime_format_with_dayfirst (self ):
84
- ambiguous_string = '01/01/2011'
85
- assert parsing ._guess_datetime_format (
86
- ambiguous_string , dayfirst = True ) == '%d/%m/%Y'
87
- assert parsing ._guess_datetime_format (
88
- ambiguous_string , dayfirst = False ) == '%m/%d/%Y'
89
85
90
- def test_guess_datetime_format_with_locale_specific_formats (self ):
86
+ result = parsing ._guess_datetime_format (string )
87
+ assert result == format
88
+
89
+ @pytest .mark .xfail (reason = "GH18141 - dateutil > 2.6.1 broken" )
90
+ @pytest .mark .parametrize (
91
+ "dayfirst, expected" ,
92
+ [
93
+ (True , "%d/%m/%Y" ),
94
+ (False , "%m/%d/%Y" )])
95
+ def test_guess_datetime_format_with_dayfirst (self , dayfirst , expected ):
96
+ ambiguous_string = '01/01/2011'
97
+ result = parsing ._guess_datetime_format (
98
+ ambiguous_string , dayfirst = dayfirst )
99
+ assert result == expected
100
+
101
+ @pytest .mark .xfail (reason = "GH18141 - dateutil > 2.6.1 broken" )
102
+ @pytest .mark .parametrize (
103
+ "string, format" ,
104
+ [
105
+ ('30/Dec/2011' , '%d/%b/%Y' ),
106
+ ('30/December/2011' , '%d/%B/%Y' ),
107
+ ('30/Dec/2011 00:00:00' , '%d/%b/%Y %H:%M:%S' )])
108
+ def test_guess_datetime_format_with_locale_specific_formats (
109
+ self , string , format ):
91
110
# The month names will vary depending on the locale, in which
92
111
# case these wont be parsed properly (dateutil can't parse them)
93
112
tm ._skip_if_has_locale ()
94
113
95
- dt_string_to_format = (('30/Dec/2011' , '%d/%b/%Y' ),
96
- ('30/December/2011' , '%d/%B/%Y' ),
97
- ('30/Dec/2011 00:00:00' , '%d/%b/%Y %H:%M:%S' ), )
98
-
99
- for dt_string , dt_format in dt_string_to_format :
100
- assert parsing ._guess_datetime_format (dt_string ) == dt_format
114
+ result = parsing ._guess_datetime_format (string )
115
+ assert result == format
101
116
102
117
def test_guess_datetime_format_invalid_inputs (self ):
103
118
# A datetime string must include a year, month and a day for it
@@ -117,17 +132,20 @@ def test_guess_datetime_format_invalid_inputs(self):
117
132
for invalid_dt in invalid_dts :
118
133
assert parsing ._guess_datetime_format (invalid_dt ) is None
119
134
120
- def test_guess_datetime_format_nopadding (self ):
135
+ @pytest .mark .xfail (reason = "GH18141 - dateutil > 2.6.1 broken" )
136
+ @pytest .mark .parametrize (
137
+ "string, format" ,
138
+ [
139
+ ('2011-1-1' , '%Y-%m-%d' ),
140
+ ('30-1-2011' , '%d-%m-%Y' ),
141
+ ('1/1/2011' , '%m/%d/%Y' ),
142
+ ('2011-1-1 00:00:00' , '%Y-%m-%d %H:%M:%S' ),
143
+ ('2011-1-1 0:0:0' , '%Y-%m-%d %H:%M:%S' ),
144
+ ('2011-1-3T00:00:0' , '%Y-%m-%dT%H:%M:%S' )])
145
+ def test_guess_datetime_format_nopadding (self , string , format ):
121
146
# GH 11142
122
- dt_string_to_format = (('2011-1-1' , '%Y-%m-%d' ),
123
- ('30-1-2011' , '%d-%m-%Y' ),
124
- ('1/1/2011' , '%m/%d/%Y' ),
125
- ('2011-1-1 00:00:00' , '%Y-%m-%d %H:%M:%S' ),
126
- ('2011-1-1 0:0:0' , '%Y-%m-%d %H:%M:%S' ),
127
- ('2011-1-3T00:00:0' , '%Y-%m-%dT%H:%M:%S' ))
128
-
129
- for dt_string , dt_format in dt_string_to_format :
130
- assert parsing ._guess_datetime_format (dt_string ) == dt_format
147
+ result = parsing ._guess_datetime_format (string )
148
+ assert result == format
131
149
132
150
133
151
class TestArrayToDatetime (object ):
0 commit comments