2015-07-24 03:56:21 +03:00
|
|
|
import pytest
|
2015-07-25 03:01:03 +03:00
|
|
|
from tests.functional.plots import with_confirmation, without_confirmation, \
|
2015-07-30 18:28:20 +03:00
|
|
|
refuse_with_confirmation, history_changed, history_not_changed, \
|
2015-09-06 13:29:42 +03:00
|
|
|
select_command_with_arrows, how_to_configure
|
2015-09-06 00:56:18 +03:00
|
|
|
|
2015-07-24 03:56:21 +03:00
|
|
|
|
2017-09-01 07:10:16 +02:00
|
|
|
python_3 = (u'thefuck/python3-bash',
|
|
|
|
u'FROM python:3',
|
|
|
|
u'sh')
|
2015-07-24 03:56:21 +03:00
|
|
|
|
2017-09-01 07:10:16 +02:00
|
|
|
python_2 = (u'thefuck/python2-bash',
|
|
|
|
u'FROM python:2',
|
|
|
|
u'sh')
|
|
|
|
|
|
|
|
|
|
|
|
init_bashrc = u'''echo '
|
|
|
|
export SHELL=/bin/bash
|
|
|
|
export PS1="$ "
|
|
|
|
echo > $HISTFILE
|
|
|
|
eval $(thefuck --alias {})
|
2017-10-08 17:16:15 +02:00
|
|
|
echo "instant mode ready: $THEFUCK_INSTANT_MODE"
|
2017-09-01 07:10:16 +02:00
|
|
|
' > ~/.bashrc'''
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(params=[(python_3, False),
|
|
|
|
(python_3, True),
|
|
|
|
(python_2, False)])
|
2016-08-13 14:50:21 +03:00
|
|
|
def proc(request, spawnu, TIMEOUT):
|
2017-09-01 07:10:16 +02:00
|
|
|
container, instant_mode = request.param
|
|
|
|
proc = spawnu(*container)
|
2016-08-13 14:11:18 +03:00
|
|
|
proc.sendline(u"pip install /src")
|
2016-08-13 14:50:21 +03:00
|
|
|
assert proc.expect([TIMEOUT, u'Successfully installed'])
|
2017-09-01 07:10:16 +02:00
|
|
|
proc.sendline(init_bashrc.format(
|
|
|
|
u'--enable-experimental-instant-mode' if instant_mode else ''))
|
|
|
|
proc.sendline(u"bash")
|
2017-10-08 17:16:15 +02:00
|
|
|
if instant_mode:
|
|
|
|
assert proc.expect([TIMEOUT, u'instant mode ready: True'])
|
2015-07-29 16:30:32 +03:00
|
|
|
return proc
|
|
|
|
|
|
|
|
|
2015-09-06 01:13:44 +03:00
|
|
|
@pytest.mark.functional
|
2016-08-13 14:11:18 +03:00
|
|
|
def test_with_confirmation(proc, TIMEOUT):
|
2015-09-06 00:56:18 +03:00
|
|
|
with_confirmation(proc, TIMEOUT)
|
2016-08-13 14:11:18 +03:00
|
|
|
history_changed(proc, TIMEOUT, u'echo test')
|
2015-07-30 18:28:20 +03:00
|
|
|
|
|
|
|
|
2015-09-06 01:13:44 +03:00
|
|
|
@pytest.mark.functional
|
2016-08-13 14:11:18 +03:00
|
|
|
def test_select_command_with_arrows(proc, TIMEOUT):
|
2015-09-06 00:56:18 +03:00
|
|
|
select_command_with_arrows(proc, TIMEOUT)
|
2016-08-13 14:11:18 +03:00
|
|
|
history_changed(proc, TIMEOUT, u'git help')
|
2015-07-24 03:56:21 +03:00
|
|
|
|
|
|
|
|
2015-09-06 01:13:44 +03:00
|
|
|
@pytest.mark.functional
|
2016-08-13 14:11:18 +03:00
|
|
|
def test_refuse_with_confirmation(proc, TIMEOUT):
|
2015-09-06 00:56:18 +03:00
|
|
|
refuse_with_confirmation(proc, TIMEOUT)
|
2016-08-13 14:11:18 +03:00
|
|
|
history_not_changed(proc, TIMEOUT)
|
2015-07-24 23:14:58 +03:00
|
|
|
|
|
|
|
|
2015-09-06 01:13:44 +03:00
|
|
|
@pytest.mark.functional
|
2016-08-13 14:11:18 +03:00
|
|
|
def test_without_confirmation(proc, TIMEOUT):
|
2015-09-06 00:56:18 +03:00
|
|
|
without_confirmation(proc, TIMEOUT)
|
2016-08-13 14:11:18 +03:00
|
|
|
history_changed(proc, TIMEOUT, u'echo test')
|
2015-09-06 13:29:42 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.functional
|
|
|
|
def test_how_to_configure_alias(proc, TIMEOUT):
|
2017-03-28 12:28:34 +02:00
|
|
|
proc.sendline('unset -f fuck')
|
2015-09-06 13:29:42 +03:00
|
|
|
how_to_configure(proc, TIMEOUT)
|