Skip to content
Merged
Changes from 1 commit
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
38 changes: 38 additions & 0 deletions pandas/tests/tslibs/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import numpy as np
import pytest

from pandas._config import set_option

from pandas._libs.tslibs import (
parsing,
strptime,
Expand Down Expand Up @@ -421,3 +423,39 @@ def test_hypothesis_delimited_date(

assert except_out_dateutil == except_in_dateutil
assert result == expected


@pytest.mark.parametrize("input", ["21-01-01", "01-01-21"])
@pytest.mark.parametrize("dayfirst", [True, False])
def test_parse_datetime_string_with_reso_dayfirst(dayfirst, input):
set_option("display.date_dayfirst", dayfirst)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the option_context context manager instead (and below)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, PTAL.

except_out_dateutil, result = _helper_hypothesis_delimited_date(
parsing.parse_datetime_string_with_reso, input
)
except_in_dateutil, expected = _helper_hypothesis_delimited_date(
du_parse,
input,
default=datetime(1, 1, 1),
dayfirst=dayfirst,
yearfirst=False,
)
assert except_out_dateutil == except_in_dateutil
assert result[0] == expected


@pytest.mark.parametrize("input", ["21-01-01", "01-01-21"])
@pytest.mark.parametrize("yearfirst", [True, False])
def test_parse_datetime_string_with_reso_yearfirst(yearfirst, input):
set_option("display.date_yearfirst", yearfirst)
except_out_dateutil, result = _helper_hypothesis_delimited_date(
parsing.parse_datetime_string_with_reso, input
)
except_in_dateutil, expected = _helper_hypothesis_delimited_date(
du_parse,
input,
default=datetime(1, 1, 1),
dayfirst=False,
yearfirst=yearfirst,
)
assert except_out_dateutil == except_in_dateutil
assert result[0] == expected
Loading