142
142
for part in test_case.parts:
143
143
if part.part_type =="file":
144
self.add_file_test(part)
145
145
elif part.part_type =="stdout":
146
add_stdout_test(part)
146
self.add_stdout_test(part)
147
147
elif part.part_type =="stderr":
148
add_stderr_test(part)
148
self.add_stderr_test(part)
149
149
elif part.part_type =="result":
150
add_result_test(part)
150
self.add_result_test(part)
151
151
elif part.part_type =="exception":
152
add_exception_test(part)
152
self.add_exception_test(part)
153
153
elif part.part_type =="code":
154
self.add_code_test(part)
156
156
def _set_default_function(self, function, test_type):
157
157
""""Ensure test type is valid and set function to a default
208
208
def add_result_test(self, part):
209
209
"Test part that compares function return values"
210
210
function = self._set_default_function(part.data, part.test_type)
211
self._result_test = (test_type, function)
211
self._result_test = (part.test_type, function)
213
213
def add_stdout_test(self, part):
214
214
"Test part that compares stdout"
215
215
function = self._set_default_function(part.data, part.test_type)
216
self._stdout_test = (test_type, function)
216
self._stdout_test = (part.test_type, function)
218
218
def add_stderr_test(self, part):
219
219
"Test part that compares stderr"
220
220
function = self._set_default_function(part.data, part.test_type)
221
self._stderr_test = (test_type, function)
221
self._stderr_test = (part.test_type, function)
223
223
def add_exception_test(self, part):
224
224
"Test part that compares stderr"
225
225
function = self._set_default_function(part.data, part.test_type)
226
self._exception_test = (test_type, function)
226
self._exception_test = (part.test_type, function)
228
228
def add_file_test(self, part):
229
229
"Test part that compares the contents of a specified file"
230
230
function = self._set_default_function(part.data, part.test_type)
231
self._file_tests[part.filename] = (test_type, function)
231
self._file_tests[part.filename] = (part.test_type, function)
233
233
def add_code_test(self, part):
234
234
"Test part that examines the supplied code"
235
235
function = self._set_default_function(part.data, part.test_type)
236
self._code_test = (test_type, function)
236
self._code_test = (part.test_type, function)
238
238
def _check_output(self, solution_output, attempt_output, test_type, f):
239
239
"""Compare solution output and attempt output using the
585
585
raise TestCreationError("Bad include code")
587
587
self._include_space = include_space
589
589
def add_case(self, test_case):
590
590
""" Add a TestCase, then validate all functions inside test case
591
591
now that the include code is known