Skip to content

TST: insert 'match' to bare pytest raises in pandas/tests/tseries/off… #36682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions pandas/tests/tseries/offsets/test_ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,15 @@ def test_tick_rdiv(cls):
off = cls(10)
delta = off.delta
td64 = delta.to_timedelta64()
instance__type = ".".join([cls.__module__, cls.__name__])
msg = (
"unsupported operand type\\(s\\) for \\/: 'int'|'float' and "
f"'{instance__type}'"
)

with pytest.raises(TypeError):
with pytest.raises(TypeError, match=msg):
2 / off
with pytest.raises(TypeError):
with pytest.raises(TypeError, match=msg):
2.0 / off

assert (td64 * 2.5) / off == 2.5
Expand Down Expand Up @@ -330,14 +335,20 @@ def test_compare_ticks_to_strs(cls):
assert not off == "infer"
assert not "foo" == off

instance_type = ".".join([cls.__module__, cls.__name__])
msg = (
"'<'|'<='|'>'|'>=' not supported between instances of "
f"'str' and '{instance_type}'|'{instance_type}' and 'str'"
)

for left, right in [("infer", off), (off, "infer")]:
with pytest.raises(TypeError):
with pytest.raises(TypeError, match=msg):
left < right
with pytest.raises(TypeError):
with pytest.raises(TypeError, match=msg):
left <= right
with pytest.raises(TypeError):
with pytest.raises(TypeError, match=msg):
left > right
with pytest.raises(TypeError):
with pytest.raises(TypeError, match=msg):
left >= right


Expand Down