Skip to content

CI: update exception catching for np1.21 #40697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,8 @@ def maybe_cast_to_datetime(
except ValueError:
# TODO(GH#40048): only catch dateutil's ParserError
# once we can reliably import it in all supported versions
if is_timedelta64:
raise
pass

# coerce datetimelike to object
Expand Down
7 changes: 6 additions & 1 deletion pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ def test_array_of_dt64_nat_with_td64dtype_raises(self, frame_or_series):
if frame_or_series is DataFrame:
arr = arr.reshape(1, 1)

msg = "Could not convert object to NumPy timedelta"
msg = "|".join(
[
"Could not convert object to NumPy timedelta",
"Invalid type for timedelta scalar: <class 'numpy.datetime64'>",
]
)
with pytest.raises(ValueError, match=msg):
frame_or_series(arr, dtype="m8[ns]")

Expand Down
7 changes: 6 additions & 1 deletion pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,12 @@ def test_constructor_dtype_timedelta64(self):
td.astype("int32")

# this is an invalid casting
msg = "Could not convert object to NumPy timedelta"
msg = "|".join(
[
"Could not convert object to NumPy timedelta",
"Could not convert 'foo' to NumPy timedelta",
]
)
with pytest.raises(ValueError, match=msg):
Series([timedelta(days=1), "foo"], dtype="m8[ns]")

Expand Down