def run_tmux(*args, term='screen', **kwargs): cmd = (sys.executable, '-mcoverage', 'run', '-m', 'babi', *args) cmd = ('env', f'TERM={term}', *cmd) with PrintsErrorRunner(*cmd, **kwargs) as h, h.on_error(): # startup with coverage can be slow h.await_text(VERSION_STR, timeout=2) yield h
def run_tmux(*args, colors=256, **kwargs): cmd = (sys.executable, '-mcoverage', 'run', '-m', 'babi', *args) quoted = ' '.join(shlex.quote(p) for p in cmd) term = 'screen-256color' if colors == 256 else 'screen' cmd = ('bash', '-c', f'export TERM={term}; exec {quoted}') with PrintsErrorRunner(*cmd, **kwargs) as h, h.on_error(): # startup with coverage can be slow h.await_text(VERSION_STR, timeout=2) yield h
def test_open_from_stdin(): with PrintsErrorRunner('env', 'TERM=screen', 'bash', '--norc') as h: cmd = (sys.executable, '-mcoverage', 'run', '-m', 'babi', '-') babi_cmd = ' '.join(shlex.quote(part) for part in cmd) h.press_and_enter(fr"echo $'hello\nworld' | {babi_cmd}") h.await_text(VERSION_STR, timeout=2) h.await_text('<<new file>> *') h.await_text('hello\nworld') h.press('^X') h.press('n') h.await_text_missing('<<new file>>') h.press_and_enter('exit') h.await_exit()
def test_suspend(tmpdir): f = tmpdir.join('f') f.write('hello') with PrintsErrorRunner('env', 'TERM=screen', 'bash', '--norc') as h: cmd = (sys.executable, '-mcoverage', 'run', '-m', 'babi', str(f)) h.press_and_enter(' '.join(shlex.quote(part) for part in cmd)) h.await_text(VERSION_STR, timeout=2) h.await_text('hello') h.press('^Z') h.await_text_missing('hello') h.press_and_enter('fg') h.await_text('hello') h.press('^X') h.press_and_enter('exit') h.await_exit()