@@ -24,20 +24,19 @@ class TestDialect(csv.excel):
2424
2525 csv .register_dialect ("test" , TestDialect )
2626
27- def _check_output_text (
28- self ,
29- _ : MessageCounter ,
30- expected_output : list [OutputLine ],
31- actual_output : list [OutputLine ],
32- ) -> None :
27+ def _runTest (self ) -> None :
3328 """Overwrite or remove the expected output file based on actual output."""
34- # Remove the expected file if no output is actually emitted and a file exists
35- if not actual_output :
36- if os .path .exists (self ._test_file .expected_output ):
37- os .remove (self ._test_file .expected_output )
38- return
39- # Write file with expected output
40- with open (self ._test_file .expected_output , "w" , encoding = "utf-8" ) as f :
41- writer = csv .writer (f , dialect = "test" )
42- for line in actual_output :
43- writer .writerow (line .to_csv ())
29+ try :
30+ super ()._runTest ()
31+ finally :
32+ actual_messages , actual_output = self ._get_actual ()
33+ # Remove the expected file if no output is actually emitted and a file exists
34+ if not actual_output :
35+ if os .path .exists (self ._test_file .expected_output ):
36+ os .remove (self ._test_file .expected_output )
37+ return
38+ # Write file with expected output
39+ with open (self ._test_file .expected_output , "w" , encoding = "utf-8" ) as f :
40+ writer = csv .writer (f , dialect = "test" )
41+ for line in actual_output :
42+ writer .writerow (line .to_csv ())
0 commit comments