def test_ignore(): cmd = create_cmd() add_comm(cmd) add_comm2(cmd) add_quit(cmd) cmd.exec_command_line("comm") assert cmd.stdout.getvalue() == COMM_TEXT + '\n' assert not IGNORE(cmd) cmd.queue("quit") cmd.run() assert cmd.stdout.getvalue() == COMM_TEXT + '\n'
def test_repeat_last(): cmd = create_cmd() add_comm(cmd) add_comm2(cmd) add_quit(cmd) cmd.exec_command_line("comm") assert cmd.stdout.getvalue() == COMM_TEXT + '\n' assert not REPEAT_LAST(cmd) cmd.queue("quit") cmd.run() assert cmd.stdout.getvalue() == COMM_TEXT + '\n' + COMM_TEXT + '\n'
def test_load(tmpdir): cmd = create_cmd() add_comm(cmd) add_comm2(cmd) add_comm3(cmd) add_quit(cmd) fname = os.path.join(tmpdir.strpath, "load.txt") with open(fname, "w") as f_out: f_out.write("comm\n") f_out.write("comm3\n") f_out.write("comm2\n") f_out.write("quit\n") assert not LOAD(cmd, fname) cmd.run() expected_lines = [ COMM_TEXT, COMM_TEXT3, COMM_TEXT2, '', ] assert cmd.stdout.getvalue() == '\n'.join(expected_lines)