Skip to content

Commit 40fd6b4

Browse files
authored
TST: xfail dateutil > 2.6.1 tests (#18240)
xref #18141
1 parent fbe15d0 commit 40fd6b4

File tree

2 files changed

+55
-35
lines changed

2 files changed

+55
-35
lines changed

pandas/tests/indexes/datetimes/test_tools.py

+2
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,8 @@ def test_dayfirst(self, cache):
995995

996996

997997
class TestGuessDatetimeFormat(object):
998+
999+
@pytest.mark.xfail(reason="GH18141 - dateutil > 2.6.1 broken")
9981000
def test_guess_datetime_format_for_array(self):
9991001
tm._skip_if_not_us_locale()
10001002
expected_format = '%Y-%m-%d %H:%M:%S.%f'

pandas/tests/scalar/test_parsing.py

+53-35
Original file line numberDiff line numberDiff line change
@@ -67,37 +67,52 @@ def test_parsers_monthfreq(self):
6767

6868

6969
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):
7184
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'
8985

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):
91110
# The month names will vary depending on the locale, in which
92111
# case these wont be parsed properly (dateutil can't parse them)
93112
tm._skip_if_has_locale()
94113

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
101116

102117
def test_guess_datetime_format_invalid_inputs(self):
103118
# 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):
117132
for invalid_dt in invalid_dts:
118133
assert parsing._guess_datetime_format(invalid_dt) is None
119134

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):
121146
# 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
131149

132150

133151
class TestArrayToDatetime(object):

0 commit comments

Comments
 (0)