@@ -5264,7 +5264,11 @@ def test_replace(self):
5264
5264
5265
5265
# malformed
5266
5266
self .assertRaises (ValueError , ser .replace , [1 , 2 , 3 ], [np .nan , 0 ])
5267
- self .assertRaises (TypeError , ser .replace , range (1 , 3 ), [np .nan , 0 ])
5267
+
5268
+ # make sure that we aren't just masking a TypeError because bools don't
5269
+ # implement indexing
5270
+ with tm .assertRaisesRegexp (TypeError , 'Cannot compare types .+' ):
5271
+ ser .replace ([1 , 2 ], [np .nan , 0 ])
5268
5272
5269
5273
ser = Series ([0 , 1 , 2 , 3 , 4 ])
5270
5274
result = ser .replace ([0 , 1 , 2 , 3 , 4 ], [4 , 3 , 2 , 1 , 0 ])
@@ -5369,9 +5373,8 @@ def test_replace_bool_with_bool(self):
5369
5373
5370
5374
def test_replace_with_dict_with_bool_keys (self ):
5371
5375
s = Series ([True , False , True ])
5372
- result = s .replace ({'asdf' : 'asdb' , True : 'yes' })
5373
- expected = Series (['yes' , False , 'yes' ])
5374
- tm .assert_series_equal (expected , result )
5376
+ with tm .assertRaisesRegexp (TypeError , 'Cannot compare types .+' ):
5377
+ s .replace ({'asdf' : 'asdb' , True : 'yes' })
5375
5378
5376
5379
def test_asfreq (self ):
5377
5380
ts = Series ([0. , 1. , 2. ], index = [datetime (2009 , 10 , 30 ),
0 commit comments