Skip to content

Commit 3a39d25

Browse files
xr-chenmroeschke
andauthored
TST: Add additional test for future warning when call Series.str.cat(Series.str) (#47755)
* fix 28277 * fix typo * add test * Update pandas/tests/strings/test_cat.py Co-authored-by: Matthew Roeschke <[email protected]> * fix pep 8 issue, change comment symbol Co-authored-by: Matthew Roeschke <[email protected]>
1 parent a7c5773 commit 3a39d25

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/tests/strings/test_cat.py

+19
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,22 @@ def test_cat_different_classes(klass):
376376
result = s.str.cat(klass(["x", "y", "z"]))
377377
expected = Series(["ax", "by", "cz"])
378378
tm.assert_series_equal(result, expected)
379+
380+
381+
def test_cat_on_series_dot_str():
382+
# GH 28277
383+
# Test future warning of `Series.str.__iter__`
384+
ps = Series(["AbC", "de", "FGHI", "j", "kLLLm"])
385+
with tm.assert_produces_warning(FutureWarning):
386+
ps.str.cat(others=ps.str)
387+
# TODO(2.0): The following code can be uncommented
388+
# when `Series.str.__iter__` is removed.
389+
390+
# message = re.escape(
391+
# "others must be Series, Index, DataFrame, np.ndarray "
392+
# "or list-like (either containing only strings or "
393+
# "containing only objects of type Series/Index/"
394+
# "np.ndarray[1-dim])"
395+
# )
396+
# with pytest.raises(TypeError, match=message):
397+
# ps.str.cat(others=ps.str)

0 commit comments

Comments
 (0)