@@ -464,7 +464,7 @@ def test_timestamp_and_label(self):
464464 data_label = 'This is a data file.'
465465 with tm .ensure_clean () as path :
466466 original .to_stata (path , time_stamp = time_stamp , data_label = data_label )
467-
467+
468468 with StataReader (path ) as reader :
469469 parsed_time_stamp = dt .datetime .strptime (reader .time_stamp , ('%d %b %Y %H:%M' ))
470470 assert parsed_time_stamp == time_stamp
@@ -475,10 +475,8 @@ def test_numeric_column_names(self):
475475 original .index .name = 'index'
476476 with tm .ensure_clean () as path :
477477 # should get a warning for that format.
478- with warnings .catch_warnings (record = True ) as w :
479- tm .assert_produces_warning (original .to_stata (path ), InvalidColumnName )
480- # should produce a single warning
481- tm .assert_equal (len (w ), 1 )
478+ with tm .assert_produces_warning (InvalidColumnName ):
479+ original .to_stata (path )
482480
483481 written_and_read_again = self .read_dta (path )
484482 written_and_read_again = written_and_read_again .set_index ('index' )
@@ -530,11 +528,8 @@ def test_large_value_conversion(self):
530528 original = DataFrame ({'s0' : s0 , 's1' : s1 , 's2' : s2 , 's3' : s3 })
531529 original .index .name = 'index'
532530 with tm .ensure_clean () as path :
533- with warnings .catch_warnings (record = True ) as w :
534- tm .assert_produces_warning (original .to_stata (path ),
535- PossiblePrecisionLoss )
536- # should produce a single warning
537- tm .assert_equal (len (w ), 1 )
531+ with tm .assert_produces_warning (PossiblePrecisionLoss ):
532+ original .to_stata (path )
538533
539534 written_and_read_again = self .read_dta (path )
540535 modified = original .copy ()
@@ -548,10 +543,8 @@ def test_dates_invalid_column(self):
548543 original = DataFrame ([datetime (2006 , 11 , 19 , 23 , 13 , 20 )])
549544 original .index .name = 'index'
550545 with tm .ensure_clean () as path :
551- with warnings .catch_warnings (record = True ) as w :
552- tm .assert_produces_warning (original .to_stata (path , {0 : 'tc' }),
553- InvalidColumnName )
554- tm .assert_equal (len (w ), 1 )
546+ with tm .assert_produces_warning (InvalidColumnName ):
547+ original .to_stata (path , {0 : 'tc' })
555548
556549 written_and_read_again = self .read_dta (path )
557550 modified = original .copy ()
0 commit comments