@@ -43,18 +43,18 @@ def _assert_exit_code_zero(pattern: Pattern) -> None:
4343 assert pretty == GOLDEN
4444
4545
46- def _skipped_tests (test_dir : Path , slow_tests_file : Path , failing_tests_file : Path ) -> dict [Path , list [str ]]:
46+ def _skipped_tests (test_dir : Path , slow_tests_file : Path , failing_tests_file : Path ) -> dict [Path , frozenset [str ]]:
4747 try :
4848 slow_tests = read_csv_file (slow_tests_file )
4949 except FileNotFoundError as e :
5050 _LOGGER .warning (e )
5151 slow_tests = ()
5252 failing_tests = read_csv_file (failing_tests_file )
53- skipped : dict [Path , list [str ]] = {}
53+ skipped : dict [Path , set [str ]] = {}
5454 for test_file , test in slow_tests + failing_tests :
5555 test_file = test_dir / test_file
56- skipped .setdefault (test_file , []). append (test )
57- return skipped
56+ skipped .setdefault (test_file , set ()). add (test )
57+ return { k : frozenset ( v ) for k , v in skipped . items ()}
5858
5959
6060def read_csv_file (csv_file : Path ) -> tuple [tuple [Path , str ], ...]:
@@ -71,25 +71,27 @@ def _test(
7171 usegas : bool ,
7272 save_failing : bool ,
7373 compute_chain_id : Callable [[str ], int ],
74- skipped_tests : dict [Path , list [str ]],
74+ skipped_tests : dict [Path , frozenset [str ]],
7575 test_dir : Path ,
7676 failing_tests_file : Path ,
7777) -> None :
78- skipped_gst_tests = skipped_tests .get (gst_file , [] )
78+ skipped_gst_tests = skipped_tests .get (gst_file , frozenset () )
7979 if '*' in skipped_gst_tests :
8080 pytest .skip ()
8181
82- failing_tests : list [str ] = []
8382 gst_file_relative_path : Final [str ] = str (gst_file .relative_to (test_dir ))
8483
8584 with gst_file .open () as f :
8685 gst_data = json .load (f )
8786
87+ failing_tests : list [str ] = []
88+
89+ chain_id = compute_chain_id (gst_file_relative_path )
90+
8891 for test_name , test in gst_data .items ():
8992 _LOGGER .info (f'Running test: { gst_file } - { test_name } ' )
9093 if test_name in skipped_gst_tests :
9194 continue
92- chain_id = compute_chain_id (gst_file_relative_path )
9395 res = interpret ({test_name : test }, schedule , mode , chain_id , usegas , check = False )
9496
9597 try :
@@ -99,14 +101,14 @@ def _test(
99101 raise
100102 failing_tests .append (test_name )
101103
102- if not failing_tests :
104+ if len ( failing_tests ) == 0 :
103105 return
104- if save_failing :
105- with failing_tests_file .open ('a' , newline = '' ) as ff :
106- writer = csv .writer (ff )
107- if len (failing_tests ) == len (gst_data ):
108- writer .writerow ([gst_file_relative_path , '*' ])
109- else :
110- for test_name in sorted (failing_tests ):
111- writer .writerow ([gst_file_relative_path , test_name ])
106+
107+ with failing_tests_file .open ('a' , newline = '' ) as ff :
108+ writer = csv .writer (ff )
109+ if len (failing_tests ) == len (gst_data ):
110+ writer .writerow ([gst_file_relative_path , '*' ])
111+ else :
112+ for test_name in sorted (failing_tests ):
113+ writer .writerow ([gst_file_relative_path , test_name ])
112114 raise AssertionError (f'Found failing tests in GST file { gst_file_relative_path } : { failing_tests } ' )
0 commit comments