def run_show_cmd(hist_args, commands, base_idx=0, step=1): stdout.seek(0, io.SEEK_SET) stdout.truncate() history._main(hist, hist_args) # pylint: disable=protected-access stdout.seek(0, io.SEEK_SET) hist_lines = stdout.readlines() yield assert_equal, len(commands), len(hist_lines) for idx, (cmd, actual) in enumerate(zip(commands, hist_lines)): expected = format_hist_line(base_idx + idx * step, cmd) yield assert_equal, expected, actual
def run_show_cmd(hist_args, commands, base_idx=0, step=1): """Run and evaluate the output of the given show command.""" stdout.seek(0, io.SEEK_SET) stdout.truncate() history._main(hist, hist_args) stdout.seek(0, io.SEEK_SET) hist_lines = stdout.readlines() yield assert_equal, len(commands), len(hist_lines) for idx, (cmd, actual) in enumerate(zip(commands, hist_lines)): expected = format_hist_line(base_idx + idx * step, cmd) yield assert_equal, expected, actual