Skip to content

Commit df4d1d5

Browse files
author
Rajat Bishnoi
committed
TST: insert 'match' to bare pytest raises in pandas/tests/tseries/offsets/test_ticks.py
1 parent 027f365 commit df4d1d5

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

pandas/tests/tseries/offsets/test_ticks.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,15 @@ def test_tick_rdiv(cls):
267267
delta = off.delta
268268
td64 = delta.to_timedelta64()
269269

270-
with pytest.raises(TypeError):
270+
msg = (
271+
"unsupported operand type\\(s\\) for \\/: 'int'|'float' and "
272+
f"'{'.'.join([cls.__module__, cls.__name__])}'"
273+
)
274+
275+
with pytest.raises(TypeError, match=msg):
271276
2 / off
272-
with pytest.raises(TypeError):
277+
278+
with pytest.raises(TypeError, match=msg):
273279
2.0 / off
274280

275281
assert (td64 * 2.5) / off == 2.5
@@ -331,13 +337,18 @@ def test_compare_ticks_to_strs(cls):
331337
assert not "foo" == off
332338

333339
for left, right in [("infer", off), (off, "infer")]:
334-
with pytest.raises(TypeError):
340+
instance_type = ".".join([cls.__module__, cls.__name__])
341+
msg = (
342+
"'<'|'<='|'>'|'>=' not supported between instances of "
343+
f"'str' and '{instance_type}'|'{instance_type}' and 'str'"
344+
)
345+
with pytest.raises(TypeError, match=msg):
335346
left < right
336-
with pytest.raises(TypeError):
347+
with pytest.raises(TypeError, match=msg):
337348
left <= right
338-
with pytest.raises(TypeError):
349+
with pytest.raises(TypeError, match=msg):
339350
left > right
340-
with pytest.raises(TypeError):
351+
with pytest.raises(TypeError, match=msg):
341352
left >= right
342353

343354

0 commit comments

Comments
 (0)