|
10 | 10 | timezone,
|
11 | 11 | )
|
12 | 12 | from io import StringIO
|
| 13 | +import warnings |
13 | 14 |
|
14 | 15 | from dateutil.parser import parse as du_parse
|
15 | 16 | from hypothesis import given
|
@@ -1664,16 +1665,16 @@ def test_invalid_parse_delimited_date(all_parsers, date_string):
|
1664 | 1665 | "date_string,dayfirst,expected",
|
1665 | 1666 | [
|
1666 | 1667 | # %d/%m/%Y; month > 12 thus replacement
|
1667 |
| - ("13/02/2019", False, datetime(2019, 2, 13)), |
1668 | 1668 | ("13/02/2019", True, datetime(2019, 2, 13)),
|
1669 | 1669 | # %m/%d/%Y; day > 12 thus there will be no replacement
|
1670 | 1670 | ("02/13/2019", False, datetime(2019, 2, 13)),
|
1671 |
| - ("02/13/2019", True, datetime(2019, 2, 13)), |
1672 | 1671 | # %d/%m/%Y; dayfirst==True thus replacement
|
1673 | 1672 | ("04/02/2019", True, datetime(2019, 2, 4)),
|
1674 | 1673 | ],
|
1675 | 1674 | )
|
1676 |
| -def test_parse_delimited_date_swap(all_parsers, date_string, dayfirst, expected): |
| 1675 | +def test_parse_delimited_date_swap_no_warning( |
| 1676 | + all_parsers, date_string, dayfirst, expected |
| 1677 | +): |
1677 | 1678 | parser = all_parsers
|
1678 | 1679 | expected = DataFrame({0: [expected]}, dtype="datetime64[ns]")
|
1679 | 1680 | result = parser.read_csv(
|
@@ -1750,9 +1751,11 @@ def test_hypothesis_delimited_date(
|
1750 | 1751 | )
|
1751 | 1752 | date_string = test_datetime.strftime(date_format.replace(" ", delimiter))
|
1752 | 1753 |
|
1753 |
| - except_out_dateutil, result = _helper_hypothesis_delimited_date( |
1754 |
| - parse_datetime_string, date_string, dayfirst=dayfirst |
1755 |
| - ) |
| 1754 | + with warnings.catch_warnings(): |
| 1755 | + warnings.filterwarnings("ignore", category=UserWarning) |
| 1756 | + except_out_dateutil, result = _helper_hypothesis_delimited_date( |
| 1757 | + parse_datetime_string, date_string, dayfirst=dayfirst |
| 1758 | + ) |
1756 | 1759 | except_in_dateutil, expected = _helper_hypothesis_delimited_date(
|
1757 | 1760 | du_parse,
|
1758 | 1761 | date_string,
|
|
0 commit comments