Skip to content

TST: add error message match for raise in test_datetimelike.py GH30999 #37952

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 3 commits into from
Nov 20, 2020
Merged
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
17 changes: 15 additions & 2 deletions pandas/tests/arrays/test_datetimelike.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from typing import Type, Union

import numpy as np
Expand Down Expand Up @@ -302,10 +303,22 @@ def test_searchsorted_castable_strings(self, arr1d, box):
expected = np.array([1, 2], dtype=np.intp)
tm.assert_numpy_array_equal(result, expected)

with pytest.raises(TypeError):
with pytest.raises(
TypeError,
match=re.escape(
f"value should be a '{arr1d._scalar_type.__name__}', 'NaT', "
"or array of those. Got 'str' instead."
),
):
arr.searchsorted("foo")

with pytest.raises(TypeError):
with pytest.raises(
TypeError,
match=re.escape(
f"value should be a '{arr1d._scalar_type.__name__}', 'NaT', "
"or array of those. Got 'StringArray' instead."
),
):
arr.searchsorted([str(arr[1]), "baz"])

def test_getitem_2d(self, arr1d):
Expand Down