Skip to content

Commit

Permalink
TST: GH30999 Add match=msg to test_nat_comparisons_invalid (#38564)
Browse files Browse the repository at this point in the history
  • Loading branch information
moink authored Dec 18, 2020
1 parent b578be4 commit e68016c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pandas/tests/scalar/test_nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,20 +558,28 @@ def test_nat_comparisons_numpy(other):
assert not NaT >= other


@pytest.mark.parametrize("other", ["foo", 2, 2.0])
@pytest.mark.parametrize("op", [operator.le, operator.lt, operator.ge, operator.gt])
def test_nat_comparisons_invalid(other, op):
@pytest.mark.parametrize("other_and_type", [("foo", "str"), (2, "int"), (2.0, "float")])
@pytest.mark.parametrize(
"symbol_and_op",
[("<=", operator.le), ("<", operator.lt), (">=", operator.ge), (">", operator.gt)],
)
def test_nat_comparisons_invalid(other_and_type, symbol_and_op):
# GH#35585
other, other_type = other_and_type
symbol, op = symbol_and_op

assert not NaT == other
assert not other == NaT

assert NaT != other
assert other != NaT

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

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


Expand Down

0 comments on commit e68016c

Please sign in to comment.