Skip to content

Commit b98f2eb

Browse files
BUG: Renamed test and added raise and ignore cases pandas-dev#45319
1 parent 4ea55b1 commit b98f2eb

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

pandas/tests/tools/test_to_datetime.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -2779,16 +2779,28 @@ def test_to_datetime_monotonic_increasing_index(cache):
27792779
"series_length",
27802780
[40, start_caching_at, (start_caching_at + 1), (start_caching_at + 5)],
27812781
)
2782-
def test_to_datetime_cache_coerce_50_lines(series_length):
2782+
def test_to_datetime_cache_coerce_50_lines_outofbounds(series_length):
27832783
# GH#45319
27842784
s = Series(
27852785
[datetime.fromisoformat("1446-04-12 00:00:00+00:00")]
27862786
+ ([datetime.fromisoformat("1991-10-20 00:00:00+00:00")] * series_length)
27872787
)
2788-
result = to_datetime(s, errors="coerce", utc=True)
2788+
result1 = to_datetime(s, errors="coerce", utc=True)
27892789

2790-
expected = Series(
2790+
expected1 = Series(
27912791
[NaT] + ([Timestamp("1991-10-20 00:00:00+00:00")] * series_length)
27922792
)
27932793

2794-
tm.assert_series_equal(result, expected)
2794+
tm.assert_series_equal(result1, expected1)
2795+
2796+
result2 = to_datetime(s, errors="ignore", utc=True)
2797+
2798+
expected2 = Series(
2799+
[datetime.fromisoformat("1446-04-12 00:00:00+00:00")]
2800+
+ ([datetime.fromisoformat("1991-10-20 00:00:00+00:00")] * series_length)
2801+
)
2802+
2803+
tm.assert_series_equal(result2, expected2)
2804+
2805+
with pytest.raises(OutOfBoundsDatetime, match="Out of bounds nanosecond timestamp"):
2806+
to_datetime(s, errors="raise", utc=True)

0 commit comments

Comments
 (0)