Skip to content

Commit ca296ec

Browse files
committed
Fix more tests
1 parent ca3b8fe commit ca296ec

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

pandas/tests/frame/test_reductions.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,17 @@ class TestDataFrameAnalytics:
167167
pytest.param("kurt", marks=td.skip_if_no_scipy),
168168
],
169169
)
170-
def test_stat_op_api_float_string_frame(self, float_string_frame, axis, opname):
171-
if (opname in ("sum", "min", "max") and axis == 0) or opname in (
172-
"count",
173-
"nunique",
174-
):
170+
def test_stat_op_api_float_string_frame(
171+
self, float_string_frame, axis, opname, using_infer_string
172+
):
173+
if (
174+
(opname in ("sum", "min", "max") and axis == 0)
175+
or opname
176+
in (
177+
"count",
178+
"nunique",
179+
)
180+
) and not (using_infer_string and opname == "sum"):
175181
getattr(float_string_frame, opname)(axis=axis)
176182
else:
177183
if opname in ["var", "std", "sem", "skew", "kurt"]:
@@ -197,7 +203,11 @@ def test_stat_op_api_float_string_frame(self, float_string_frame, axis, opname):
197203
elif opname in ["min", "max"]:
198204
msg = "'[><]=' not supported between instances of 'float' and 'str'"
199205
elif opname == "median":
200-
msg = re.compile(r"Cannot convert \[.*\] to numeric", flags=re.S)
206+
msg = re.compile(
207+
r"Cannot convert \[.*\] to numeric|does not support", flags=re.S
208+
)
209+
if not isinstance(msg, re.Pattern):
210+
msg = msg + "|does not support"
201211
with pytest.raises(TypeError, match=msg):
202212
getattr(float_string_frame, opname)(axis=axis)
203213
if opname != "nunique":
@@ -358,6 +368,7 @@ def test_mixed_ops(self, op):
358368
"Could not convert",
359369
"could not convert",
360370
"can't multiply sequence by non-int",
371+
"does not support",
361372
]
362373
)
363374
with pytest.raises(TypeError, match=msg):
@@ -369,6 +380,7 @@ def test_mixed_ops(self, op):
369380
"Could not convert",
370381
"could not convert",
371382
"can't multiply sequence by non-int",
383+
"does not support",
372384
]
373385
)
374386
with pytest.raises(TypeError, match=msg):
@@ -887,7 +899,8 @@ def test_sum_mixed_datetime(self):
887899

888900
def test_mean_corner(self, float_frame, float_string_frame):
889901
# unit test when have object data
890-
with pytest.raises(TypeError, match="Could not convert"):
902+
msg = "Could not convert|does not support"
903+
with pytest.raises(TypeError, match=msg):
891904
float_string_frame.mean(axis=0)
892905

893906
# xs sum mixed type, just want to know it works...

0 commit comments

Comments
 (0)