@@ -5270,7 +5270,11 @@ def test_replace(self):
5270
5270
5271
5271
# malformed
5272
5272
self .assertRaises (ValueError , ser .replace , [1 , 2 , 3 ], [np .nan , 0 ])
5273
- self .assertRaises (TypeError , ser .replace , range (1 , 3 ), [np .nan , 0 ])
5273
+
5274
+ # make sure that we aren't just masking a TypeError because bools don't
5275
+ # implement indexing
5276
+ with tm .assertRaisesRegexp (TypeError , 'Cannot compare types .+' ):
5277
+ ser .replace ([1 , 2 ], [np .nan , 0 ])
5274
5278
5275
5279
ser = Series ([0 , 1 , 2 , 3 , 4 ])
5276
5280
result = ser .replace ([0 , 1 , 2 , 3 , 4 ], [4 , 3 , 2 , 1 , 0 ])
@@ -5375,9 +5379,8 @@ def test_replace_bool_with_bool(self):
5375
5379
5376
5380
def test_replace_with_dict_with_bool_keys (self ):
5377
5381
s = Series ([True , False , True ])
5378
- result = s .replace ({'asdf' : 'asdb' , True : 'yes' })
5379
- expected = Series (['yes' , False , 'yes' ])
5380
- tm .assert_series_equal (expected , result )
5382
+ with tm .assertRaisesRegexp (TypeError , 'Cannot compare types .+' ):
5383
+ s .replace ({'asdf' : 'asdb' , True : 'yes' })
5381
5384
5382
5385
def test_asfreq (self ):
5383
5386
ts = Series ([0. , 1. , 2. ], index = [datetime (2009 , 10 , 30 ),
0 commit comments