def test_block_special_char(expected_results): with Runner(*dstatic_cmd()) as h: h.default_timeout = 2 h.await_text(expected_results) h.write("Q") h.press("Enter") h.await_exit()
def test_pymatrix_screen_resize_height_too_short(): with Runner(*pymatrix_run("--test_mode"), width=50, height=50) as h: h.await_text("T") h.tmux.execute_command('split-window', '-vt0', '-l', 40) h.await_text("Error screen height is to short.") sc = h.screenshot() assert "T" not in sc
def test_pymatrix_zero_one_command_line(): with Runner(*pymatrix_run("-z", "-l"), width=75, height=50) as h: h.await_text("0") h.await_text("1") sc = h.screenshot() assert "T" not in sc assert "5" not in sc
def test_cutev_ctrl_x_close_single_file(tmpdir): tf = tmpdir.join("a.txt") tf.write("test test test") with Runner(*run_cutev(tf.strpath)) as h: h.await_text("a.txt") h.press("^x") h.await_exit()
def test_cutev_last_line_show_blank(tmpdir): tf = tmpdir.join("foo.py") tf.write(sample_file_small()) with Runner(*run_cutev(tf.strpath, "-l"), height=13) as h: h.await_text("foo.py") captured = h.screenshot() assert "10" in captured.splitlines()[-3:]
def test_pymatrix_screen_resize_width_very_narrow(): # note test can be flaky with Runner(*pymatrix_run("--test_mode", "-d1"), width=50, height=50) as h: h.default_timeout = 3 h.await_text("T") h.tmux.execute_command('split-window', '-ht0', '-l', 45) h.await_text("T")
def test_dstatic_disable_keys_quit_works(test_keys): with Runner(*dstatic_cmd("-D")) as h: h.default_timeout = 3 h.await_text(chr(9617)) h.write(test_keys) h.press("Enter") h.await_exit()
def test_pymatrix_quit_screen_saver_mode(test_key): with Runner(*pymatrix_run("--test_mode", "-s", "-d1")) as h: h.default_timeout = 2 h.await_text("T") h.write(test_key) h.press("Enter") h.await_exit()
def test_cutev_no_filename_passed(): with Runner("bash") as h: h.write("clear") h.press("Enter") h.write("python3 cutev/cutev.py") h.press("Enter") h.await_text("usage:")
def test_dstatic_disable_all_keys_screensaver_works(test_keys): with Runner(*dstatic_cmd("--disable_all_keys", "-S")) as h: h.default_timeout = 3 h.await_text(chr(9617)) h.write(test_keys) h.press("Enter") h.await_exit()
def test_dstatic_exit(test_key): """ Tests dstatic.py will exit on q or Q""" with Runner(*dstatic_cmd()) as h: h.await_text(chr(9617)) h.write(test_key) h.press("Enter") h.await_exit()
def test_cutev_quit(cmd, tmpdir): tf = tmpdir.join("foo.py") tf.write("# foo.py\n\nprint('hello world')") with Runner(*run_cutev(tf.strpath)) as h: h.await_text("foo.py") h.write(cmd) h.press("Enter") h.await_exit()
def test_cutev_line_number(tmpdir): tf1 = tmpdir.join("foo.py") tf1.write(sample_file_small()) with Runner(*run_cutev(tf1.strpath, "-l")) as h: h.await_text("foo.py") h.await_text("1") captured = h.screenshot() assert "1# sample python 3 file" in captured
def test_black_and_white_command(): with Runner(*dstatic_cmd()) as h: h.write("b") h.press("Enter") h.await_text(chr(9617)) h.write("Q") h.press("Enter") h.await_exit()
def test_cutev_multiple_files_open(tmpdir): tf1 = tmpdir.join("foo.py") tf1.write(sample_file_small()) tf2 = tmpdir.join("bar.py") tf2.write(sample_file_medium()) with Runner(*run_cutev(tf1.strpath, tf2.strpath)) as h: h.await_text("foo.py 1 / 2") h.await_text("# sample python 3 file")
def test_cutev_file_not_found(tmpdir): tf = tmpdir.join("bar.py") with Runner("bash") as h: h.write("clear") h.press("Enter") h.write(f"python3 cutev/cutev.py {tf.strpath}") h.press("Enter") h.await_text("No files loaded")
def test_pymatrix_freeze_quit(): with Runner(*pymatrix_run("--test_mode"), width=100, height=10) as h: h.default_timeout = 2 h.await_text("T") h.write("f") sleep(0.05) h.write("q") h.await_exit()
def test_color_command(): with Runner(*dstatic_cmd()) as h: h.write("C") h.press("Enter") h.await_text(chr(9617)) h.write("Q") h.press("Enter") h.await_exit()
def test_dstatic_start_timer(): """ Test start timer.""" with Runner(*dstatic_cmd("-s2")) as h: h.default_timeout = 3 h.await_text(chr(9617)) h.write("Q") h.press("Enter") h.await_exit()
def test_cutev_multiple_files_open_one_not_found(tmpdir): tf1 = tmpdir.join("foo.py") tf1.write(sample_file_small()) tf2 = tmpdir.join("bar.py") tf3 = tmpdir.join("a") tf3.write("test test test") with Runner(*run_cutev(tf1.strpath, tf2.strpath, tf3.strpath)) as h: h.await_text("foo.py 1 / 2")
def test_cutev_ctrl_a_close_all_except_current_only_one_open(tmpdir): tf1 = tmpdir.join("foo.py") tf1.write(sample_file_small()) with Runner(*run_cutev(tf1.strpath)) as h: h.await_text("foo.py") h.await_text("# sample python 3 file") h.press("^a") h.await_text("foo.py") h.await_text("# sample python 3 file")
def test_cutev_last_line_show_line(tmpdir): tf = tmpdir.join("foo.txt") tf.write("test test test\npost toasties") with Runner(*run_cutev(tf.strpath, "-l")) as h: h.await_text("foo.txt") h.await_text("1test test test") h.await_text("2post toasties") captured = h.screenshot() assert "3" not in captured
def test_dstatic_exit_black_white_mode(test_key): """ Tests dstatic.py will exit on q or Q when using black and white mode """ with Runner(*dstatic_cmd("-b")) as h: h.await_text(chr(9617)) h.write(test_key) h.press("Enter") h.await_exit()
def test_pymatrix_freeze_no_other_keys(): with Runner(*pymatrix_run("--test_mode"), width=100, height=10) as h: h.default_timeout = 2 h.await_text("T") h.write("f") sleep(0.05) sc = h.screenshot() h.write("z") sleep(0.5) assert h.screenshot() == sc
def test_dstatic_exit_delay_set(test_key): """ Tests dstatic.py will exit on q or Q when setting delay time """ with Runner(*dstatic_cmd("-d1")) as h: h.await_text(chr(9617)) h.write(test_key) h.press("Enter") h.await_exit()
def test_cutev_goto_line_zero(tmpdir): tf = tmpdir.join("foo.py") tf.write(sample_file_small()) with Runner(*run_cutev(tf.strpath), height=20) as h: h.await_text("foo.py") h.write("g") h.await_text("Go to line:") h.write("0") captured = h.screenshot() assert "Go to line: 0" not in captured
def test_dstatic_disable_all_keys_check_quit(test_keys): with Runner(*dstatic_cmd("--disable_all_keys", "--test_mode")) as h: h.default_timeout = 1 h.await_text("0") h.write(test_keys) h.press("Enter") time.sleep(1) h.await_text("0") sc = h.screenshot() assert "$" not in sc
def test_cutev_line_off_screen(tmpdir): tf = tmpdir.join("foo.py") data = "a" * 85 tf.write(data) with Runner(*run_cutev(tf.strpath), width=80) as h: h.await_text("foo.py") h.await_text("a") captured = h.screenshot() expected = "a" * 79 + "$" assert captured.splitlines()[1] == expected
def test_cutev_multiple_files_quit(tmpdir): tf1 = tmpdir.join("foo.py") tf1.write(sample_file_small()) tf2 = tmpdir.join("bar.py") tf2.write(sample_file_medium()) with Runner(*run_cutev(tf1.strpath, tf2.strpath)) as h: h.await_text("foo.py 1 / 2") h.write("q") h.press("Enter") h.await_exit()
def test_dstatic_exit_screen_save_mode(test_keys): """ Test a same of any key will exit dstatic in screen save mode. """ with Runner(*dstatic_cmd("-S")) as h: h.await_text(chr(9617)) h.write(test_keys) h.press("Enter") h.await_exit()