1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 02:41:10 +01:00
thefuck/tests/functional/test_zsh.py

76 lines
2.1 KiB
Python
Raw Normal View History

2015-07-24 01:56:21 +01:00
import pytest
2015-07-25 01:22:05 +01:00
from tests.functional.plots import with_confirmation, without_confirmation, \
refuse_with_confirmation, history_changed, history_not_changed, \
select_command_with_arrows, how_to_configure
2015-07-24 01:56:21 +01:00
python_3 = ('thefuck/python3-zsh',
u'''FROM python:3
RUN apt-get update
RUN apt-get install -yy zsh''',
u'sh')
python_2 = ('thefuck/python2-zsh',
u'''FROM python:2
RUN apt-get update
RUN apt-get install -yy zsh''',
u'sh')
init_zshrc = u'''echo '
export SHELL=/usr/bin/zsh
export HISTFILE=~/.zsh_history
echo > $HISTFILE
export SAVEHIST=100
export HISTSIZE=100
eval $(thefuck --alias {})
setopt INC_APPEND_HISTORY
echo "instant mode ready: $THEFUCK_INSTANT_MODE"
' > ~/.zshrc'''
@pytest.fixture(params=[(python_3, False),
(python_3, True),
(python_2, False)])
def proc(request, spawnu, TIMEOUT):
container, instant_mode = request.param
proc = spawnu(*container)
proc.sendline(u'pip install /src')
assert proc.expect([TIMEOUT, u'Successfully installed'])
proc.sendline(init_zshrc.format(
u'--enable-experimental-instant-mode' if instant_mode else ''))
proc.sendline(u"zsh")
if instant_mode:
assert proc.expect([TIMEOUT, u'instant mode ready: True'])
2015-07-29 14:30:32 +01:00
return proc
2015-09-05 23:13:44 +01:00
@pytest.mark.functional
def test_with_confirmation(proc, TIMEOUT):
with_confirmation(proc, TIMEOUT)
history_changed(proc, TIMEOUT, u'echo test')
2015-07-30 16:28:20 +01:00
2015-09-05 23:13:44 +01:00
@pytest.mark.functional
def test_select_command_with_arrows(proc, TIMEOUT):
select_command_with_arrows(proc, TIMEOUT)
history_changed(proc, TIMEOUT, u'git help')
2015-07-24 01:56:21 +01:00
2015-09-05 23:13:44 +01:00
@pytest.mark.functional
def test_refuse_with_confirmation(proc, TIMEOUT):
refuse_with_confirmation(proc, TIMEOUT)
history_not_changed(proc, TIMEOUT)
2015-07-24 21:14:58 +01:00
2015-09-05 23:13:44 +01:00
@pytest.mark.functional
def test_without_confirmation(proc, TIMEOUT):
without_confirmation(proc, TIMEOUT)
history_changed(proc, TIMEOUT, u'echo test')
@pytest.mark.functional
def test_how_to_configure_alias(proc, TIMEOUT):
2017-03-28 11:28:34 +01:00
proc.sendline(u'unfunction fuck')
how_to_configure(proc, TIMEOUT)