33import numpy as np
44import pytest
55
6+ from pandas .compat import is_numpy_dev
7+
68import pandas as pd
79import pandas ._testing as tm
810
@@ -98,11 +100,6 @@ def test_pos_numeric(self, df):
98100 @pytest .mark .parametrize (
99101 "df" ,
100102 [
101- # numpy changing behavior in the future
102- pytest .param (
103- pd .DataFrame ({"a" : ["a" , "b" ]}),
104- marks = [pytest .mark .filterwarnings ("ignore" )],
105- ),
106103 pd .DataFrame ({"a" : np .array ([- 1 , 2 ], dtype = object )}),
107104 pd .DataFrame ({"a" : [Decimal ("-1.0" ), Decimal ("2.0" )]}),
108105 ],
@@ -112,6 +109,25 @@ def test_pos_object(self, df):
112109 tm .assert_frame_equal (+ df , df )
113110 tm .assert_series_equal (+ df ["a" ], df ["a" ])
114111
112+ @pytest .mark .parametrize (
113+ "df" ,
114+ [
115+ pytest .param (
116+ pd .DataFrame ({"a" : ["a" , "b" ]}),
117+ marks = [pytest .mark .filterwarnings ("ignore" )],
118+ ),
119+ ],
120+ )
121+ def test_pos_object_raises (self , df ):
122+ # GH#21380
123+ if is_numpy_dev :
124+ with pytest .raises (
125+ TypeError , match = r"^bad operand type for unary \+: \'str\'$"
126+ ):
127+ tm .assert_frame_equal (+ df , df )
128+ else :
129+ tm .assert_series_equal (+ df ["a" ], df ["a" ])
130+
115131 @pytest .mark .parametrize (
116132 "df" , [pd .DataFrame ({"a" : pd .to_datetime (["2017-01-22" , "1970-01-01" ])})]
117133 )
0 commit comments