Skip to content

Commit e68016c

Browse files
authored
TST: GH30999 Add match=msg to test_nat_comparisons_invalid (#38564)
1 parent b578be4 commit e68016c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pandas/tests/scalar/test_nat.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -558,20 +558,28 @@ def test_nat_comparisons_numpy(other):
558558
assert not NaT >= other
559559

560560

561-
@pytest.mark.parametrize("other", ["foo", 2, 2.0])
562-
@pytest.mark.parametrize("op", [operator.le, operator.lt, operator.ge, operator.gt])
563-
def test_nat_comparisons_invalid(other, op):
561+
@pytest.mark.parametrize("other_and_type", [("foo", "str"), (2, "int"), (2.0, "float")])
562+
@pytest.mark.parametrize(
563+
"symbol_and_op",
564+
[("<=", operator.le), ("<", operator.lt), (">=", operator.ge), (">", operator.gt)],
565+
)
566+
def test_nat_comparisons_invalid(other_and_type, symbol_and_op):
564567
# GH#35585
568+
other, other_type = other_and_type
569+
symbol, op = symbol_and_op
570+
565571
assert not NaT == other
566572
assert not other == NaT
567573

568574
assert NaT != other
569575
assert other != NaT
570576

571-
with pytest.raises(TypeError):
577+
msg = f"'{symbol}' not supported between instances of 'NaTType' and '{other_type}'"
578+
with pytest.raises(TypeError, match=msg):
572579
op(NaT, other)
573580

574-
with pytest.raises(TypeError):
581+
msg = f"'{symbol}' not supported between instances of '{other_type}' and 'NaTType'"
582+
with pytest.raises(TypeError, match=msg):
575583
op(other, NaT)
576584

577585

0 commit comments

Comments
 (0)