Skip to content

Commit

Permalink
TST: Add additional test for future warning when call Series.str.cat(…
Browse files Browse the repository at this point in the history
…Series.str) (#47755)

* fix 28277

* fix typo

* add test

* Update pandas/tests/strings/test_cat.py

Co-authored-by: Matthew Roeschke <emailformattr@gmail.com>

* fix pep 8 issue, change comment symbol

Co-authored-by: Matthew Roeschke <emailformattr@gmail.com>
  • Loading branch information
xr-chen and mroeschke authored Jul 19, 2022
1 parent a7c5773 commit 3a39d25
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pandas/tests/strings/test_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,22 @@ def test_cat_different_classes(klass):
result = s.str.cat(klass(["x", "y", "z"]))
expected = Series(["ax", "by", "cz"])
tm.assert_series_equal(result, expected)


def test_cat_on_series_dot_str():
# GH 28277
# Test future warning of `Series.str.__iter__`
ps = Series(["AbC", "de", "FGHI", "j", "kLLLm"])
with tm.assert_produces_warning(FutureWarning):
ps.str.cat(others=ps.str)
# TODO(2.0): The following code can be uncommented
# when `Series.str.__iter__` is removed.

# message = re.escape(
# "others must be Series, Index, DataFrame, np.ndarray "
# "or list-like (either containing only strings or "
# "containing only objects of type Series/Index/"
# "np.ndarray[1-dim])"
# )
# with pytest.raises(TypeError, match=message):
# ps.str.cat(others=ps.str)

0 comments on commit 3a39d25

Please sign in to comment.