diff --git a/pandas/tests/arrays/test_datetimelike.py b/pandas/tests/arrays/test_datetimelike.py index 94a5406eb1f8f..159f52a4c7c25 100644 --- a/pandas/tests/arrays/test_datetimelike.py +++ b/pandas/tests/arrays/test_datetimelike.py @@ -1,3 +1,4 @@ +import re from typing import Type, Union import numpy as np @@ -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):