@@ -82,9 +82,15 @@ def test_run_solutions(create_package, time_tool):
82
82
command .time_limit = command .config ["time_limit" ]
83
83
command .timetool_path = util .get_oiejq_path ()
84
84
85
- print (command .compile_and_run (["abc.cpp" ]))
86
- assert command .compile_and_run (["abc.cpp" ]) == {"abc.cpp" : {1 : "OK" , 2 : "OK" , 3 : "OK" , 4 : "OK" }}
87
- assert command .compile_and_run (["abc.cpp" , "abc4.cpp" ]) == {
85
+ def flatten_results (results ):
86
+ new_results = {}
87
+ for solution in results .keys ():
88
+ new_results [solution ] = dict ((group , group_result ["status" ])
89
+ for group , group_result in results [solution ].items ())
90
+ return new_results
91
+
92
+ assert flatten_results (command .compile_and_run (["abc.cpp" ])[0 ]) == {"abc.cpp" : {1 : "OK" , 2 : "OK" , 3 : "OK" , 4 : "OK" }}
93
+ assert flatten_results (command .compile_and_run (["abc.cpp" , "abc4.cpp" ])[0 ]) == {
88
94
"abc.cpp" : {1 : "OK" , 2 : "OK" , 3 : "OK" , 4 : "OK" },
89
95
"abc4.cpp" : {1 : "OK" , 2 : "OK" , 3 : "WA" , 4 : "RE" }
90
96
}
@@ -126,7 +132,7 @@ def test_validate_expected_scores_success():
126
132
# Test with correct expected scores.
127
133
command .args = argparse .Namespace (solutions = ["prog/abc.cpp" ], tests = None )
128
134
results = {
129
- "abc.cpp" : {1 : " OK" , 2 : " OK" , 3 : " OK" , 4 : " OK" },
135
+ "abc.cpp" : {1 : { "status" : " OK" , "points" : 25 }, 2 : { "status" : " OK" , "points" : 25 }, 3 : { "status" : " OK" , "points" : 25 }, 4 : { "status" : " OK", "points" : 25 } },
130
136
}
131
137
results = command .validate_expected_scores (results )
132
138
assert results .expected_scores == results .new_expected_scores
@@ -135,7 +141,7 @@ def test_validate_expected_scores_success():
135
141
# Test with incorrect result.
136
142
command .args = argparse .Namespace (solutions = ["prog/abc.cpp" ], tests = None )
137
143
results = {
138
- "abc.cpp" : {1 : " OK" , 2 : " OK" , 3 : " OK" , 4 : " WA" },
144
+ "abc.cpp" : {1 : { "status" : " OK" , "points" : 25 }, 2 : { "status" : " OK" , "points" : 25 }, 3 : { "status" : " OK" , "points" : 25 }, 4 : { "status" : " WA", "points" : 0 } },
139
145
}
140
146
results = command .validate_expected_scores (results )
141
147
assert results .expected_scores != results .new_expected_scores
@@ -144,10 +150,10 @@ def test_validate_expected_scores_success():
144
150
# Test with removed solution.
145
151
command .args = argparse .Namespace (solutions = None , tests = None )
146
152
results = {
147
- "abc.cpp" : {1 : " OK" , 2 : " OK" , 3 : " OK" , 4 : " OK" },
148
- "abc1.cpp" : {1 : " OK" , 2 : " OK" , 3 : " OK" , 4 : " WA" },
149
- "abc2.cpp" : {1 : " OK" , 2 : " WA" , 3 : " WA" , 4 : " TL" },
150
- "abc3.cpp" : {1 : " OK" , 2 : " WA" , 3 : " WA" , 4 : " ML" },
153
+ "abc.cpp" : {1 : { "status" : " OK" , "points" : 25 }, 2 : { "status" : " OK" , "points" : 25 }, 3 : { "status" : " OK" , "points" : 25 }, 4 : { "status" : " OK", "points" : 25 } },
154
+ "abc1.cpp" : {1 : { "status" : " OK" , "points" : 25 }, 2 : { "status" : " OK" , "points" : 25 }, 3 : { "status" : " OK" , "points" : 25 }, 4 : { "status" : " WA", "points" : 0 } },
155
+ "abc2.cpp" : {1 : { "status" : " OK" , "points" : 25 }, 2 : { "status" : " WA" , "points" : 0 }, 3 : { "status" : " WA" , "points" : 0 }, 4 : { "status" : " TL", "points" : 0 } },
156
+ "abc3.cpp" : {1 : { "status" : " OK" , "points" : 25 }, 2 : { "status" : " WA" , "points" : 0 }, 3 : { "status" : " WA" , "points" : 0 }, 4 : { "status" : " ML", "points" : 0 } },
151
157
}
152
158
results = command .validate_expected_scores (results )
153
159
assert results .expected_scores != results .new_expected_scores
@@ -157,8 +163,8 @@ def test_validate_expected_scores_success():
157
163
command .config ["scores" ][5 ] = 0
158
164
command .args = argparse .Namespace (solutions = ["prog/abc.cpp" , "prog/abc5.cpp" ], tests = None )
159
165
results = {
160
- "abc.cpp" : {1 : " OK" , 2 : " OK" , 3 : " OK" , 4 : " OK" , 5 : " WA" },
161
- "abc5.cpp" : {1 : " OK" , 2 : " OK" , 3 : " OK" , 4 : " OK" , 5 : " WA" },
166
+ "abc.cpp" : {1 : { "status" : " OK" , "points" : 20 }, 2 : { "status" : " OK" , "points" : 20 }, 3 : { "status" : " OK" , "points" : 20 }, 4 : { "status" : " OK" , "points" : 20 }, 5 : { "status" : " WA", "points" : 0 } },
167
+ "abc5.cpp" : {1 : { "status" : " OK" , "points" : 20 }, 2 : { "status" : " OK" , "points" : 20 }, 3 : { "status" : " OK" , "points" : 20 }, 4 : { "status" : " OK" , "points" : 20 }, 5 : { "status" : " WA", "points" : 0 } },
162
168
}
163
169
results = command .validate_expected_scores (results )
164
170
assert results .expected_scores != results .new_expected_scores
@@ -168,7 +174,7 @@ def test_validate_expected_scores_success():
168
174
# Test with removed group.
169
175
command .args = argparse .Namespace (solutions = ["prog/abc.cpp" ], tests = None )
170
176
results = {
171
- "abc.cpp" : {1 : " OK" , 2 : " OK" , 3 : " OK" },
177
+ "abc.cpp" : {1 : { "status" : " OK" , "points" : 25 }, 2 : { "status" : " OK" , "points" : 25 }, 3 : { "status" : " OK", "points" : 25 } },
172
178
}
173
179
results = command .validate_expected_scores (results )
174
180
assert results .expected_scores != results .new_expected_scores
@@ -177,7 +183,7 @@ def test_validate_expected_scores_success():
177
183
# Test with correct expected scores and --tests flag.
178
184
command .args = argparse .Namespace (solutions = ["prog/abc.cpp" ], tests = ["in/abc1a.in" , "in/abc2a.in" ])
179
185
results = {
180
- "abc.cpp" : {1 : " OK" , 2 : " OK" },
186
+ "abc.cpp" : {1 : { "status" : " OK" , "points" : 25 }, 2 : { "status" : " OK", "points" : 25 } },
181
187
}
182
188
results = command .validate_expected_scores (results )
183
189
assert results .expected_scores == results .new_expected_scores
@@ -186,12 +192,12 @@ def test_validate_expected_scores_success():
186
192
def test_validate_expected_scores_fail (capsys ):
187
193
command = get_command ()
188
194
os .chdir (get_simple_package_path ())
189
- command .scores = command . config [ "scores" ]
195
+ command .scores = { 1 : 20 , 2 : 20 , 3 : 20 , 4 : 20 }
190
196
191
197
# Test with missing points for group in config.
192
198
command .args = argparse .Namespace (solutions = ["prog/abc.cpp" ], tests = None )
193
199
results = {
194
- "abc.cpp" : {1 : " OK" , 2 : " OK" , 3 : " OK" , 4 : " OK" , 5 : " OK" },
200
+ "abc.cpp" : {1 : { "status" : " OK" , "points" : 20 }, 2 : { "status" : " OK" , "points" : 20 }, 3 : { "status" : " OK" , "points" : 20 }, 4 : { "status" : " OK" , "points" : 20 }, 5 : { "status" : " OK", "points" : 20 } },
195
201
}
196
202
with pytest .raises (SystemExit ) as e :
197
203
command .validate_expected_scores (results )
0 commit comments