@@ -132,6 +132,18 @@ def test_cat(self):
132
132
exp = np .array (['aa' , NA , 'bb' , 'bd' , 'cfoo' , NA ], dtype = np .object_ )
133
133
tm .assert_almost_equal (result , exp )
134
134
135
+ # error for incorrect lengths
136
+ rgx = 'All arrays must be same length'
137
+ three = Series (['1' , '2' , '3' ])
138
+
139
+ with tm .assert_raises_regex (ValueError , rgx ):
140
+ strings .str_cat (one , three )
141
+
142
+ # error for incorrect type
143
+ rgx = "Must pass arrays containing strings to str_cat"
144
+ with tm .assert_raises_regex (ValueError , rgx ):
145
+ strings .str_cat (one , 'three' )
146
+
135
147
@pytest .mark .parametrize ('series_or_index' , ['series' , 'index' ])
136
148
def test_str_cat (self , series_or_index ):
137
149
# test_cat above tests "str_cat" from ndarray to ndarray;
@@ -183,7 +195,7 @@ def test_str_cat(self, series_or_index):
183
195
assert_series_or_index_equal (s .str .cat (list (t ), na_rep = '-' ), exp )
184
196
185
197
# errors for incorrect lengths
186
- rgx = 'All arrays must be same length'
198
+ rgx = 'All arrays must be same length, except.* '
187
199
z = Series (['1' , '2' , '3' ])
188
200
189
201
with tm .assert_raises_regex (ValueError , rgx ):
@@ -305,7 +317,7 @@ def test_str_cat_mixed_inputs(self, series_or_index):
305
317
assert_series_or_index_equal (s .str .cat (iter ([t .values , list (s )])), exp )
306
318
307
319
# errors for incorrect lengths
308
- rgx = 'All arrays must be same length'
320
+ rgx = 'All arrays must be same length, except.* '
309
321
z = Series (['1' , '2' , '3' ])
310
322
e = concat ([z , z ], axis = 1 )
311
323
@@ -331,7 +343,7 @@ def test_str_cat_mixed_inputs(self, series_or_index):
331
343
332
344
# errors for incorrect arguments in list-like
333
345
rgx = 'others must be Series, Index, DataFrame,.*'
334
- # make sure None/Nan also work as string-replacements
346
+ # make sure None/NaN do not crash checks in _get_series_list
335
347
u = Series (['a' , np .nan , 'c' , None ])
336
348
337
349
# mix of string and Series
0 commit comments