1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-09-19 03:32:31 +01:00

#682: Add functional tests for instant mode

This commit is contained in:
Vladimir Iakovlev
2017-09-01 07:10:16 +02:00
parent 452ac21603
commit 2e0b423f2c
2 changed files with 55 additions and 29 deletions

View File

@@ -3,22 +3,35 @@ from tests.functional.plots import with_confirmation, without_confirmation, \
refuse_with_confirmation, history_changed, history_not_changed, \ refuse_with_confirmation, history_changed, history_not_changed, \
select_command_with_arrows, how_to_configure select_command_with_arrows, how_to_configure
containers = ((u'thefuck/python3-bash',
u'FROM python:3', python_3 = (u'thefuck/python3-bash',
u'bash'), u'FROM python:3',
(u'thefuck/python2-bash', u'sh')
u'FROM python:2',
u'bash')) python_2 = (u'thefuck/python2-bash',
u'FROM python:2',
u'sh')
@pytest.fixture(params=containers) init_bashrc = u'''echo '
export SHELL=/bin/bash
export PS1="$ "
echo > $HISTFILE
eval $(thefuck --alias {})
' > ~/.bashrc'''
@pytest.fixture(params=[(python_3, False),
(python_3, True),
(python_2, False)])
def proc(request, spawnu, TIMEOUT): def proc(request, spawnu, TIMEOUT):
proc = spawnu(*request.param) container, instant_mode = request.param
proc = spawnu(*container)
proc.sendline(u"pip install /src") proc.sendline(u"pip install /src")
assert proc.expect([TIMEOUT, u'Successfully installed']) assert proc.expect([TIMEOUT, u'Successfully installed'])
proc.sendline(u"export PS1='$ '") proc.sendline(init_bashrc.format(
proc.sendline(u'eval $(thefuck --alias)') u'--enable-experimental-instant-mode' if instant_mode else ''))
proc.sendline(u'echo > $HISTFILE') proc.sendline(u"bash")
return proc return proc

View File

@@ -3,29 +3,42 @@ from tests.functional.plots import with_confirmation, without_confirmation, \
refuse_with_confirmation, history_changed, history_not_changed, \ refuse_with_confirmation, history_changed, history_not_changed, \
select_command_with_arrows, how_to_configure select_command_with_arrows, how_to_configure
containers = (('thefuck/python3-zsh',
u'''FROM python:3 python_3 = ('thefuck/python3-zsh',
RUN apt-get update u'''FROM python:3
RUN apt-get install -yy zsh''', RUN apt-get update
u'zsh'), RUN apt-get install -yy zsh''',
('thefuck/python2-zsh', u'sh')
u'''FROM python:2
RUN apt-get update python_2 = ('thefuck/python2-zsh',
RUN apt-get install -yy zsh''', u'''FROM python:2
u'zsh')) RUN apt-get update
RUN apt-get install -yy zsh''',
u'sh')
@pytest.fixture(params=containers) 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
' > ~/.zshrc'''
@pytest.fixture(params=[(python_3, False),
(python_3, True),
(python_2, False)])
def proc(request, spawnu, TIMEOUT): def proc(request, spawnu, TIMEOUT):
proc = spawnu(*request.param) container, instant_mode = request.param
proc = spawnu(*container)
proc.sendline(u'pip install /src') proc.sendline(u'pip install /src')
assert proc.expect([TIMEOUT, u'Successfully installed']) assert proc.expect([TIMEOUT, u'Successfully installed'])
proc.sendline(u'eval $(thefuck --alias)') proc.sendline(init_zshrc.format(
proc.sendline(u'export HISTFILE=~/.zsh_history') u'--enable-experimental-instant-mode' if instant_mode else ''))
proc.sendline(u'echo > $HISTFILE') proc.sendline(u"zsh")
proc.sendline(u'export SAVEHIST=100')
proc.sendline(u'export HISTSIZE=100')
proc.sendline(u'setopt INC_APPEND_HISTORY')
return proc return proc