@@ -6492,29 +6492,34 @@ def test_convert_objects(self):
6492
6492
# Remove test after deprecation to convert_objects is final
6493
6493
def test_convert_objects_old_style_deprecation (self ):
6494
6494
s = Series (['foo' , 'bar' , 1 , 1.0 ], dtype = 'O' )
6495
- with warnings .catch_warnings (record = True ) as w :
6496
- warnings .simplefilter ('always' , FutureWarning )
6497
- new_style = s .convert_objects (datetime = True , coerce = True )
6498
- old_style = s .convert_objects (convert_dates = 'coerce' )
6499
- self .assertEqual (len (w ), 2 )
6500
- assert_series_equal (new_style , old_style )
6501
-
6502
- with warnings .catch_warnings (record = True ) as w :
6503
- warnings .simplefilter ('always' , FutureWarning )
6504
- new_style = s .convert_objects (numeric = True , coerce = True )
6505
- old_style = s .convert_objects (convert_numeric = 'coerce' )
6506
- self .assertEqual (len (w ), 2 )
6507
- assert_series_equal (new_style , old_style )
6495
+ def f ():
6496
+ with tm .assert_produces_warning (FutureWarning ):
6497
+ s .convert_objects (convert_dates = 'coerce' )
6498
+ self .assertRaises (ValueError , f )
6499
+ def f ():
6500
+ with tm .assert_produces_warning (FutureWarning ):
6501
+ s .convert_objects (convert_numeric = 'coerce' )
6502
+ self .assertRaises (ValueError , f )
6508
6503
6509
6504
dt = datetime (2001 , 1 , 1 , 0 , 0 )
6510
6505
td = dt - datetime (2000 , 1 , 1 , 0 , 0 )
6511
6506
s = Series (['a' , '3.1415' , dt , td ])
6512
- with warnings .catch_warnings (record = True ) as w :
6513
- warnings .simplefilter ('always' , FutureWarning )
6514
- new_style = s .convert_objects (timedelta = True , coerce = True )
6515
- old_style = s .convert_objects (convert_timedeltas = 'coerce' )
6516
- self .assertEqual (len (w ), 2 )
6517
- assert_series_equal (new_style , old_style )
6507
+
6508
+ def f ():
6509
+ with tm .assert_produces_warning (FutureWarning ):
6510
+ s .convert_objects (convert_timedeltas = 'coerce' )
6511
+ self .assertRaises (ValueError , f )
6512
+
6513
+ # back-compat xref GH 11116
6514
+ data = """foo,bar
6515
+ 2015-09-14,True
6516
+ 2015-09-15,
6517
+ """
6518
+ df = pd .read_csv (StringIO (data ),sep = ',' )
6519
+
6520
+ # we want to be vocal about the changes
6521
+ self .assertRaises (ValueError , lambda : df .convert_objects (coerce = True ))
6522
+ self .assertRaises (ValueError , lambda : df .convert_objects ('coerce' ))
6518
6523
6519
6524
def test_convert_objects_no_arg_warning (self ):
6520
6525
s = Series (['1.0' ,'2' ])
0 commit comments