1+ import csv
12from collections import Counter
23from dataclasses import dataclass
34from enum import IntEnum
45from functools import reduce
5- from re import A
66from typing import TextIO
77
8- import csv
98
109class TestResult (IntEnum ):
1110 """Represents the result of a test case run, indicating success or a specific failure reason."""
@@ -79,13 +78,13 @@ class TestCaseSummary:
7978 """
8079 Contains summary results for the execution of a single test case.
8180 """
82-
81+
8382 backend : str
8483 """ The name of the target backend. """
8584
8685 base_name : str
8786 """ The base name of the test, not including flow or parameter suffixes. """
88-
87+
8988 flow : str
9089 """ The backend-specific flow name. Corresponds to flows registered in backends/test/suite/__init__.py. """
9190
@@ -173,8 +172,9 @@ def complete_test_session() -> RunSummary:
173172
174173 return summary
175174
175+
176176def generate_csv_report (summary : RunSummary , output : TextIO ):
177- """ Write a run summary report to a file in CSV format. """
177+ """Write a run summary report to a file in CSV format."""
178178
179179 field_names = [
180180 "Test ID" ,
@@ -183,19 +183,23 @@ def generate_csv_report(summary: RunSummary, output: TextIO):
183183 "Flow" ,
184184 "Result" ,
185185 ]
186-
186+
187187 # Tests can have custom parameters. We'll want to report them here, so we need
188188 # a list of all unique parameter names.
189189 param_names = reduce (
190190 lambda a , b : a .union (b ),
191- (set (s .params .keys ()) for s in summary .test_case_summaries if s .params is not None ),
192- set ()
191+ (
192+ set (s .params .keys ())
193+ for s in summary .test_case_summaries
194+ if s .params is not None
195+ ),
196+ set (),
193197 )
194198 field_names += (s .capitalize () for s in param_names )
195199
196200 writer = csv .DictWriter (output , field_names )
197201 writer .writeheader ()
198-
202+
199203 for record in summary .test_case_summaries :
200204 row = {
201205 "Test ID" : record .name ,
@@ -205,7 +209,5 @@ def generate_csv_report(summary: RunSummary, output: TextIO):
205209 "Result" : record .result .display_name (),
206210 }
207211 if record .params is not None :
208- row .update ({
209- k .capitalize (): v for k , v in record .params .items ()
210- })
212+ row .update ({k .capitalize (): v for k , v in record .params .items ()})
211213 writer .writerow (row )
0 commit comments