Skip to content

Commit ad9614b

Browse files
committed
Applied various suggestions from jbrock to testcases
1 parent 406cd15 commit ad9614b

File tree

1 file changed

+11
-41
lines changed

1 file changed

+11
-41
lines changed

pandas/tests/arrays/string_/test_string.py

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,13 @@ def test_mul(dtype):
251251

252252
def test_add_series(dtype):
253253
arr = pd.array(["a", "b", "c", "d"], dtype=dtype)
254-
df = pd.Series(["t", "y", "v", "w"], dtype=object)
254+
ser = pd.Series(["t", "y", "v", "w"], dtype=object)
255255

256-
result = arr + df
256+
result = arr + ser
257257
expected = pd.Series(["at", "by", "cv", "dw"]).astype(dtype)
258258
tm.assert_series_equal(result, expected)
259259

260-
result = df + arr
260+
result = ser + arr
261261
expected = pd.Series(["ta", "yb", "vc", "wd"]).astype(dtype)
262262
tm.assert_series_equal(result, expected)
263263

@@ -277,53 +277,23 @@ def test_add_strings(dtype):
277277

278278

279279
@pytest.mark.xfail(reason="GH-28527")
280-
def test_add_frame(dtype):
280+
def test_add_frame(request, dtype):
281+
if isinstance(dtype, "str[python]"):
282+
# This ONE dtype actually succeeds the test
283+
# We are manually failing it to maintain continuity
284+
mark = pytest.mark.xfail(reason="[XPASS(strict)] GH-28527")
285+
request.applymarker(mark)
281286
arr = pd.array(["a", "b", np.nan, np.nan], dtype=dtype)
282287
df = pd.DataFrame([["x", np.nan, "y", np.nan]])
283288
assert arr.__add__(df) is NotImplemented
284289

285290
result = arr + df
286291
expected = pd.DataFrame([["ax", np.nan, np.nan, np.nan]]).astype(dtype)
287-
tm.assert_frame_equal(result, expected, check_dtype=False)
292+
tm.assert_frame_equal(result, expected)
288293

289294
result = df + arr
290295
expected = pd.DataFrame([["xa", np.nan, np.nan, np.nan]]).astype(dtype)
291-
tm.assert_frame_equal(result, expected, check_dtype=False)
292-
293-
if isinstance(dtype, "str[python]"):
294-
# This ONE dtype actually succeeds the test
295-
# We are manually failing it to maintain continuity
296-
pytest.fail("Manually failed")
297-
298-
299-
@pytest.mark.parametrize(
300-
"invalid",
301-
[
302-
10,
303-
1.5,
304-
pd.Timedelta(hours=31),
305-
pd.Timestamp("2021-01-01"),
306-
True,
307-
pd.Period("2025-09"),
308-
# pd.Categorical(["test"]), #TODO causes box_pa issue, will open issue
309-
# pd.offsets.Minute(3),
310-
pd.Interval(1, 2, closed="right"),
311-
],
312-
)
313-
def test_add_frame_invalid(dtype, invalid):
314-
arr = pd.array(["a", np.nan], dtype=dtype)
315-
df = pd.DataFrame([[invalid, invalid]])
316-
317-
msg = "|".join(
318-
[
319-
r"can only concatenate str \(not \".+\"\) to str",
320-
r"unsupported operand type\(s\) for \+: '.+' and 'str'",
321-
r"operation 'add' not supported for dtype 'str|string' with dtype '.+'",
322-
"Incompatible type when converting to PyArrow dtype for operation.",
323-
]
324-
)
325-
with pytest.raises(TypeError, match=msg):
326-
arr + df
296+
tm.assert_frame_equal(result, expected)
327297

328298

329299
def test_comparison_methods_scalar(comparison_op, dtype):

0 commit comments

Comments
 (0)