def runTest(self):
"""Makes a simple test of the output"""
body = ast.parse(self.candidate_code, self.file_name, 'exec')
code = compile(self.candidate_code, self.file_name, 'exec')
format_nodes = [
node
for node in ast.walk(body)
if isinstance(node, ast.Attribute) and
node.attr == 'format' and
isinstance(node.value, ast.Str) and
'{}' in node.value.s
]
self.assertGreater(
len(format_nodes),
0,
"It should have at one format call with curly braces {}"
)
exec(code)
self.assertMultiLineEqual('Talk is cheap. Show me the code.\n',
self.__mockstdout.getvalue(),
'Output is not correct')
评论列表
文章目录