Skip to content

TST: xfail dateutil > 2.6.1 tests #18240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pandas/tests/indexes/datetimes/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,8 @@ def test_dayfirst(self, cache):


class TestGuessDatetimeFormat(object):

@pytest.mark.xfail(reason="GH18141 - dateutil > 2.6.1 broken")
def test_guess_datetime_format_for_array(self):
tm._skip_if_not_us_locale()
expected_format = '%Y-%m-%d %H:%M:%S.%f'
Expand Down
88 changes: 53 additions & 35 deletions pandas/tests/scalar/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,37 +67,52 @@ def test_parsers_monthfreq(self):


class TestGuessDatetimeFormat(object):
def test_guess_datetime_format_with_parseable_formats(self):

@pytest.mark.xfail(reason="GH18141 - dateutil > 2.6.1 broken")
@pytest.mark.parametrize(
"string, format",
[
('20111230', '%Y%m%d'),
('2011-12-30', '%Y-%m-%d'),
('30-12-2011', '%d-%m-%Y'),
('2011-12-30 00:00:00', '%Y-%m-%d %H:%M:%S'),
('2011-12-30T00:00:00', '%Y-%m-%dT%H:%M:%S'),
('2011-12-30 00:00:00.000000',
'%Y-%m-%d %H:%M:%S.%f')])
def test_guess_datetime_format_with_parseable_formats(
self, string, format):
tm._skip_if_not_us_locale()
dt_string_to_format = (('20111230', '%Y%m%d'),
('2011-12-30', '%Y-%m-%d'),
('30-12-2011', '%d-%m-%Y'),
('2011-12-30 00:00:00', '%Y-%m-%d %H:%M:%S'),
('2011-12-30T00:00:00', '%Y-%m-%dT%H:%M:%S'),
('2011-12-30 00:00:00.000000',
'%Y-%m-%d %H:%M:%S.%f'), )

for dt_string, dt_format in dt_string_to_format:
assert parsing._guess_datetime_format(dt_string) == dt_format

def test_guess_datetime_format_with_dayfirst(self):
ambiguous_string = '01/01/2011'
assert parsing._guess_datetime_format(
ambiguous_string, dayfirst=True) == '%d/%m/%Y'
assert parsing._guess_datetime_format(
ambiguous_string, dayfirst=False) == '%m/%d/%Y'

def test_guess_datetime_format_with_locale_specific_formats(self):
result = parsing._guess_datetime_format(string)
assert result == format

@pytest.mark.xfail(reason="GH18141 - dateutil > 2.6.1 broken")
@pytest.mark.parametrize(
"dayfirst, expected",
[
(True, "%d/%m/%Y"),
(False, "%m/%d/%Y")])
def test_guess_datetime_format_with_dayfirst(self, dayfirst, expected):
ambiguous_string = '01/01/2011'
result = parsing._guess_datetime_format(
ambiguous_string, dayfirst=dayfirst)
assert result == expected

@pytest.mark.xfail(reason="GH18141 - dateutil > 2.6.1 broken")
@pytest.mark.parametrize(
"string, format",
[
('30/Dec/2011', '%d/%b/%Y'),
('30/December/2011', '%d/%B/%Y'),
('30/Dec/2011 00:00:00', '%d/%b/%Y %H:%M:%S')])
def test_guess_datetime_format_with_locale_specific_formats(
self, string, format):
# The month names will vary depending on the locale, in which
# case these wont be parsed properly (dateutil can't parse them)
tm._skip_if_has_locale()

dt_string_to_format = (('30/Dec/2011', '%d/%b/%Y'),
('30/December/2011', '%d/%B/%Y'),
('30/Dec/2011 00:00:00', '%d/%b/%Y %H:%M:%S'), )

for dt_string, dt_format in dt_string_to_format:
assert parsing._guess_datetime_format(dt_string) == dt_format
result = parsing._guess_datetime_format(string)
assert result == format

def test_guess_datetime_format_invalid_inputs(self):
# A datetime string must include a year, month and a day for it
Expand All @@ -117,17 +132,20 @@ def test_guess_datetime_format_invalid_inputs(self):
for invalid_dt in invalid_dts:
assert parsing._guess_datetime_format(invalid_dt) is None

def test_guess_datetime_format_nopadding(self):
@pytest.mark.xfail(reason="GH18141 - dateutil > 2.6.1 broken")
@pytest.mark.parametrize(
"string, format",
[
('2011-1-1', '%Y-%m-%d'),
('30-1-2011', '%d-%m-%Y'),
('1/1/2011', '%m/%d/%Y'),
('2011-1-1 00:00:00', '%Y-%m-%d %H:%M:%S'),
('2011-1-1 0:0:0', '%Y-%m-%d %H:%M:%S'),
('2011-1-3T00:00:0', '%Y-%m-%dT%H:%M:%S')])
def test_guess_datetime_format_nopadding(self, string, format):
# GH 11142
dt_string_to_format = (('2011-1-1', '%Y-%m-%d'),
('30-1-2011', '%d-%m-%Y'),
('1/1/2011', '%m/%d/%Y'),
('2011-1-1 00:00:00', '%Y-%m-%d %H:%M:%S'),
('2011-1-1 0:0:0', '%Y-%m-%d %H:%M:%S'),
('2011-1-3T00:00:0', '%Y-%m-%dT%H:%M:%S'))

for dt_string, dt_format in dt_string_to_format:
assert parsing._guess_datetime_format(dt_string) == dt_format
result = parsing._guess_datetime_format(string)
assert result == format


class TestArrayToDatetime(object):
Expand Down