Skip to content

Commit 63152e3

Browse files
committed
add test to count number of warnings emitted
1 parent 7d06940 commit 63152e3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/io/parser/test_parse_dates.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,16 @@ def test_parse_delimited_date_swap_with_warning(
16851685
tm.assert_frame_equal(result, expected)
16861686

16871687

1688+
def test_parse_multiple_delimited_dates_with_swap_warnings():
1689+
# GH46210
1690+
warning_msg = "Specify a format to ensure consistent parsing"
1691+
with pytest.warns(UserWarning, match=warning_msg) as record: # noqa: PDF011
1692+
# Using pytest.warns instead of tm.assert_produces_warning in order to
1693+
# count the number of warnings
1694+
pd.to_datetime(["01/01/2000", "31/05/2000", "31/05/2001", "01/02/2000"])
1695+
assert len(record) == 1
1696+
1697+
16881698
def _helper_hypothesis_delimited_date(call, date_string, **kwargs):
16891699
msg, result = None, None
16901700
try:

0 commit comments

Comments
 (0)