def runTest(self):
"""Makes a simple test of the output"""
body = ast.parse(self.candidate_code, self.file_name, 'exec')
# Looks if the code is the same as the provided code.
body_dump = ast.dump(body)
for node in self.inmutable_code.body:
self.assertTrue(body_dump.find(ast.dump(node)) >= 0,
"Provided code should not be modified")
code = compile(self.candidate_code, self.file_name, 'exec')
exec(code)
self.assertMultiLineEqual('1\n2\n3\n',
self.__mockstdout.getvalue(),
'Output is not correct')
评论列表
文章目录