|
10 | 10 | import numpy as np
|
11 | 11 | import pytest
|
12 | 12 |
|
| 13 | +from pandas._config import set_option |
| 14 | + |
13 | 15 | from pandas._libs.tslibs import (
|
14 | 16 | parsing,
|
15 | 17 | strptime,
|
@@ -421,3 +423,39 @@ def test_hypothesis_delimited_date(
|
421 | 423 |
|
422 | 424 | assert except_out_dateutil == except_in_dateutil
|
423 | 425 | assert result == expected
|
| 426 | + |
| 427 | + |
| 428 | +@pytest.mark.parametrize("input", ["21-01-01", "01-01-21"]) |
| 429 | +@pytest.mark.parametrize("dayfirst", [True, False]) |
| 430 | +def test_parse_datetime_string_with_reso_dayfirst(dayfirst, input): |
| 431 | + set_option("display.date_dayfirst", dayfirst) |
| 432 | + except_out_dateutil, result = _helper_hypothesis_delimited_date( |
| 433 | + parsing.parse_datetime_string_with_reso, input |
| 434 | + ) |
| 435 | + except_in_dateutil, expected = _helper_hypothesis_delimited_date( |
| 436 | + du_parse, |
| 437 | + input, |
| 438 | + default=datetime(1, 1, 1), |
| 439 | + dayfirst=dayfirst, |
| 440 | + yearfirst=False, |
| 441 | + ) |
| 442 | + assert except_out_dateutil == except_in_dateutil |
| 443 | + assert result[0] == expected |
| 444 | + |
| 445 | + |
| 446 | +@pytest.mark.parametrize("input", ["21-01-01", "01-01-21"]) |
| 447 | +@pytest.mark.parametrize("yearfirst", [True, False]) |
| 448 | +def test_parse_datetime_string_with_reso_yearfirst(yearfirst, input): |
| 449 | + set_option("display.date_yearfirst", yearfirst) |
| 450 | + except_out_dateutil, result = _helper_hypothesis_delimited_date( |
| 451 | + parsing.parse_datetime_string_with_reso, input |
| 452 | + ) |
| 453 | + except_in_dateutil, expected = _helper_hypothesis_delimited_date( |
| 454 | + du_parse, |
| 455 | + input, |
| 456 | + default=datetime(1, 1, 1), |
| 457 | + dayfirst=False, |
| 458 | + yearfirst=yearfirst, |
| 459 | + ) |
| 460 | + assert except_out_dateutil == except_in_dateutil |
| 461 | + assert result[0] == expected |
0 commit comments