Skip to content

Commit 1268cd3

Browse files
author
Eve
authored
TST: add error message match for raise in test_datetimelike.py GH30999 (#37952)
* TST: add error message match for raise in test_datetimelike.py GH30999 * fix missing space at the end of error msg * fix comment
1 parent b2b81d8 commit 1268cd3

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

pandas/tests/arrays/test_datetimelike.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
from typing import Type, Union
23

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

305-
with pytest.raises(TypeError):
306+
with pytest.raises(
307+
TypeError,
308+
match=re.escape(
309+
f"value should be a '{arr1d._scalar_type.__name__}', 'NaT', "
310+
"or array of those. Got 'str' instead."
311+
),
312+
):
306313
arr.searchsorted("foo")
307314

308-
with pytest.raises(TypeError):
315+
with pytest.raises(
316+
TypeError,
317+
match=re.escape(
318+
f"value should be a '{arr1d._scalar_type.__name__}', 'NaT', "
319+
"or array of those. Got 'StringArray' instead."
320+
),
321+
):
309322
arr.searchsorted([str(arr[1]), "baz"])
310323

311324
def test_getitem_2d(self, arr1d):

0 commit comments

Comments
 (0)