Skip to content

Commit 1554eb7

Browse files
use pytest.raises regexp instead of str eq
1 parent d596502 commit 1554eb7

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

pandas/tests/libs/test_hashtable.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,8 @@ def test_nan_complex_real(self):
406406
table = ht.PyObjectHashTable()
407407
table.set_item(nan1, 42)
408408
assert table.get_item(nan2) == 42
409-
with pytest.raises(KeyError, match=None) as error:
409+
with pytest.raises(KeyError, match=re.escape(repr(other))):
410410
table.get_item(other)
411-
assert str(error.value) == str(other)
412411

413412
def test_nan_complex_imag(self):
414413
nan1 = complex(1, float("nan"))
@@ -418,9 +417,8 @@ def test_nan_complex_imag(self):
418417
table = ht.PyObjectHashTable()
419418
table.set_item(nan1, 42)
420419
assert table.get_item(nan2) == 42
421-
with pytest.raises(KeyError, match=None) as error:
420+
with pytest.raises(KeyError, match=re.escape(repr(other))):
422421
table.get_item(other)
423-
assert str(error.value) == str(other)
424422

425423
def test_nan_in_tuple(self):
426424
nan1 = (float("nan"),)
@@ -437,9 +435,8 @@ def test_nan_in_nested_tuple(self):
437435
table = ht.PyObjectHashTable()
438436
table.set_item(nan1, 42)
439437
assert table.get_item(nan2) == 42
440-
with pytest.raises(KeyError, match=None) as error:
438+
with pytest.raises(KeyError, match=re.escape(repr(other))):
441439
table.get_item(other)
442-
assert str(error.value) == str(other)
443440

444441
def test_nan_in_namedtuple(self):
445442
T = namedtuple("T", ["x"])
@@ -458,9 +455,8 @@ def test_nan_in_nested_namedtuple(self):
458455
table = ht.PyObjectHashTable()
459456
table.set_item(nan1, 42)
460457
assert table.get_item(nan2) == 42
461-
with pytest.raises(KeyError, match=re.escape(repr(other))) as error:
458+
with pytest.raises(KeyError, match=re.escape(repr(other))):
462459
table.get_item(other)
463-
assert str(error.value) == str(other)
464460

465461

466462
def test_hash_equal_tuple_with_nans():

0 commit comments

Comments
 (0)