MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / flattenTestResultsToFile

Function flattenTestResultsToFile

pythonFiles/aggregateTestResults.py:105–142  ·  view source on GitHub ↗
(runResults, filename)

Source from the content-addressed store, hash-verified

103
104
105def flattenTestResultsToFile(runResults, filename):
106 resultCount = 1
107 delimiter = ""
108 with open(filename, "w") as outfile:
109 outfile.write("[\n")
110 for runResult in runResults:
111 print(f"writing results {resultCount} of {len(runResults)}")
112 resultCount += 1
113 for scenario in runResult:
114 suite = []
115 for testResult in scenario["data"]:
116 if (
117 testResult["event"] == "suite"
118 and len(str.strip(testResult["title"])) > 0
119 ):
120 suite.append(testResult["title"])
121 elif (
122 testResult["event"] == "suite end"
123 and len(str.strip(testResult["title"]))
124 and len(suite) > 0
125 ):
126 suite.pop()
127 elif "title" in testResult and "state" in testResult:
128 outfile.write(delimiter)
129 singleResult = {
130 "scenario": scenario["scenario"],
131 "suite": " - ".join(suite),
132 "testName": testResult["title"],
133 "date": scenario["date"],
134 "runUrl": scenario["runUrl"],
135 "status": testResult["state"],
136 }
137 if "duration" in testResult:
138 singleResult["duration"] = testResult["duration"]
139 outfile.write(json.dumps(singleResult))
140 delimiter = ",\n"
141
142 outfile.write("\n]\n")
143
144
145# %%

Callers 1

Calls 3

joinMethod · 0.80
writeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected