def _printed_lines(self, function, year):
"""call the function, and count the number of lines on its output"""
output = io.StringIO()
with contextlib.redirect_stdout(output):
function(year)
txt = output.getvalue()
return len(txt.splitlines())
评论列表
文章目录