-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsvwriter.py
More file actions
26 lines (23 loc) · 1017 Bytes
/
csvwriter.py
File metadata and controls
26 lines (23 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def extract_name_id(name_id: str):
"""
>>> extract_name_id("test_example[6-36]")
["test_example", "6-36"]
"""
# Extract the name of the test function ("test_example")
test_name = name_id.split('[')[0]
# Extract the id of the test ("6-36")
submission_id = name_id[name_id.find('[')+1:-1]
return [test_name, submission_id]
class SubmissionsResult:
def __init__(self):
# fieldnames represents the column names in the csv file
# it consists of an 'id' column followed by a column for each test function name
self.fieldnames = ['id']
# results example value:
# {'1234_4321': {'id': '1234_4321', 'test_func1': passed, 'test_func2': failed} }
self.results = {}
def add_submission_result(self, submission_id, test_name, outcome):
if submission_id in self.results:
self.results[submission_id][test_name] = outcome
else:
self.results[submission_id] = {'id': submission_id, test_name: outcome}