@@ -464,7 +464,7 @@ def test_timestamp_and_label(self):
464
464
data_label = 'This is a data file.'
465
465
with tm .ensure_clean () as path :
466
466
original .to_stata (path , time_stamp = time_stamp , data_label = data_label )
467
-
467
+
468
468
with StataReader (path ) as reader :
469
469
parsed_time_stamp = dt .datetime .strptime (reader .time_stamp , ('%d %b %Y %H:%M' ))
470
470
assert parsed_time_stamp == time_stamp
@@ -475,10 +475,8 @@ def test_numeric_column_names(self):
475
475
original .index .name = 'index'
476
476
with tm .ensure_clean () as path :
477
477
# 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 )
482
480
483
481
written_and_read_again = self .read_dta (path )
484
482
written_and_read_again = written_and_read_again .set_index ('index' )
@@ -530,11 +528,8 @@ def test_large_value_conversion(self):
530
528
original = DataFrame ({'s0' : s0 , 's1' : s1 , 's2' : s2 , 's3' : s3 })
531
529
original .index .name = 'index'
532
530
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 )
538
533
539
534
written_and_read_again = self .read_dta (path )
540
535
modified = original .copy ()
@@ -548,10 +543,8 @@ def test_dates_invalid_column(self):
548
543
original = DataFrame ([datetime (2006 , 11 , 19 , 23 , 13 , 20 )])
549
544
original .index .name = 'index'
550
545
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' })
555
548
556
549
written_and_read_again = self .read_dta (path )
557
550
modified = original .copy ()
0 commit comments