Skip to content

Commit 04ec58b

Browse files
committed
TST: xfail dateutil > 2.6.1 tests
xref #18141
1 parent 96a5274 commit 04ec58b

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

pandas/tests/scalar/test_parsing.py

+35-23
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,33 @@ def test_guess_datetime_format_with_parseable_formats(self):
8080
for dt_string, dt_format in dt_string_to_format:
8181
assert parsing._guess_datetime_format(dt_string) == dt_format
8282

83-
def test_guess_datetime_format_with_dayfirst(self):
83+
@pytest.mark.xfail(reason="GH18141 - dateutil > 2.6.1 broken")
84+
@pytest.mark.parametrize(
85+
"dayfirst, expected",
86+
[
87+
(True, "%d/%m/%Y"),
88+
(False, "%m/%d/%Y")])
89+
def test_guess_datetime_format_with_dayfirst(self, dayfirst, expected):
8490
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-
90-
def test_guess_datetime_format_with_locale_specific_formats(self):
91+
result = parsing._guess_datetime_format(
92+
ambiguous_string, dayfirst=dayfirst)
93+
assert result == expected
94+
95+
@pytest.mark.xfail(reason="GH18141 - dateutil > 2.6.1 broken")
96+
@pytest.mark.parametrize(
97+
"string, format",
98+
[
99+
('30/Dec/2011', '%d/%b/%Y'),
100+
('30/December/2011', '%d/%B/%Y'),
101+
('30/Dec/2011 00:00:00', '%d/%b/%Y %H:%M:%S')])
102+
def test_guess_datetime_format_with_locale_specific_formats(
103+
self, string, format):
91104
# The month names will vary depending on the locale, in which
92105
# case these wont be parsed properly (dateutil can't parse them)
93106
tm._skip_if_has_locale()
94107

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
108+
result = parsing._guess_datetime_format(string)
109+
assert result == format
101110

102111
def test_guess_datetime_format_invalid_inputs(self):
103112
# A datetime string must include a year, month and a day for it
@@ -117,17 +126,20 @@ def test_guess_datetime_format_invalid_inputs(self):
117126
for invalid_dt in invalid_dts:
118127
assert parsing._guess_datetime_format(invalid_dt) is None
119128

120-
def test_guess_datetime_format_nopadding(self):
129+
@pytest.mark.xfail(reason="GH18141 - dateutil > 2.6.1 broken")
130+
@pytest.mark.parametrize(
131+
"string, format",
132+
[
133+
('2011-1-1', '%Y-%m-%d'),
134+
('30-1-2011', '%d-%m-%Y'),
135+
('1/1/2011', '%m/%d/%Y'),
136+
('2011-1-1 00:00:00', '%Y-%m-%d %H:%M:%S'),
137+
('2011-1-1 0:0:0', '%Y-%m-%d %H:%M:%S'),
138+
('2011-1-3T00:00:0', '%Y-%m-%dT%H:%M:%S')])
139+
def test_guess_datetime_format_nopadding(self, string, format):
121140
# 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
141+
result = parsing._guess_datetime_format(string)
142+
assert result == format
131143

132144

133145
class TestArrayToDatetime(object):

0 commit comments

Comments
 (0)