1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-14 06:38:32 +00:00

Add more functional tests

This commit is contained in:
David 2020-03-24 11:35:54 +00:00
parent 59d0836b6f
commit 5d808b65f1
7 changed files with 64 additions and 4 deletions

View File

@ -83,3 +83,17 @@ def without_confirmation(proc, TIMEOUT):
def how_to_configure(proc, TIMEOUT):
proc.sendline(u'fuck')
assert proc.expect([TIMEOUT, u"alias isn't configured"])
def status_success(proc, TIMEOUT):
proc.sendline(u'git commit --allow-empty -m "Test"')
proc.sendline(u'fuck')
assert proc.expect([TIMEOUT, u'git commit --amend'])
def status_failure(proc, TIMEOUT):
proc.sendline(u'git commit -m "Test"')
proc.sendline(u'fuck')
assert proc.expect([TIMEOUT, u'git reset HEAD~'])

View File

@ -1,7 +1,8 @@
import pytest
from tests.functional.plots import with_confirmation, without_confirmation, \
refuse_with_confirmation, history_changed, history_not_changed, \
select_command_with_arrows, how_to_configure
select_command_with_arrows, how_to_configure, status_success, \
status_failure
python_3 = (u'thefuck/python3-bash',
@ -66,3 +67,13 @@ def test_without_confirmation(proc, TIMEOUT):
def test_how_to_configure_alias(proc, TIMEOUT):
proc.sendline('unset -f fuck')
how_to_configure(proc, TIMEOUT)
@pytest.mark.functional
def test_status_success(proc, TIMEOUT):
status_success(proc, TIMEOUT)
@pytest.mark.functional
def test_status_failure(proc, TIMEOUT):
status_failure(proc, TIMEOUT)

View File

@ -1,6 +1,7 @@
import pytest
from tests.functional.plots import with_confirmation, without_confirmation, \
refuse_with_confirmation, select_command_with_arrows
refuse_with_confirmation, select_command_with_arrows, status_success, \
status_failure
containers = (('thefuck/python3-fish',
u'''FROM python:3
@ -49,4 +50,14 @@ def test_refuse_with_confirmation(proc, TIMEOUT):
def test_without_confirmation(proc, TIMEOUT):
without_confirmation(proc, TIMEOUT)
@pytest.mark.functional
def test_status_success(proc, TIMEOUT):
status_success(proc, TIMEOUT)
@pytest.mark.functional
def test_status_failure(proc, TIMEOUT):
status_failure(proc, TIMEOUT)
# TODO: ensure that history changes.

View File

@ -1,6 +1,7 @@
import pytest
from tests.functional.plots import with_confirmation, without_confirmation, \
refuse_with_confirmation, select_command_with_arrows
refuse_with_confirmation, select_command_with_arrows, status_success, \
status_failure
containers = (('thefuck/python3-tcsh',
u'''FROM python:3
@ -44,4 +45,14 @@ def test_refuse_with_confirmation(proc, TIMEOUT):
def test_without_confirmation(proc, TIMEOUT):
without_confirmation(proc, TIMEOUT)
@pytest.mark.functional
def test_status_success(proc, TIMEOUT):
status_success(proc, TIMEOUT)
@pytest.mark.functional
def test_status_failure(proc, TIMEOUT):
status_failure(proc, TIMEOUT)
# TODO: ensure that history changes.

View File

@ -1,7 +1,8 @@
import pytest
from tests.functional.plots import with_confirmation, without_confirmation, \
refuse_with_confirmation, history_changed, history_not_changed, \
select_command_with_arrows, how_to_configure
select_command_with_arrows, how_to_configure, status_success, \
status_failure
python_3 = ('thefuck/python3-zsh',
@ -73,3 +74,13 @@ def test_without_confirmation(proc, TIMEOUT):
def test_how_to_configure_alias(proc, TIMEOUT):
proc.sendline(u'unfunction fuck')
how_to_configure(proc, TIMEOUT)
@pytest.mark.functional
def test_status_success(proc, TIMEOUT):
status_success(proc, TIMEOUT)
@pytest.mark.functional
def test_status_failure(proc, TIMEOUT):
status_failure(proc, TIMEOUT)

View File

@ -10,6 +10,7 @@ class Tcsh(Generic):
def app_alias(self, alias_name):
return ("alias {0} 'setenv TF_SHELL tcsh && setenv TF_ALIAS {0} && "
"setenv TF_STATUS=$status && "
"set fucked_cmd=`history -h 2 | head -n 1` && "
"eval `thefuck ${{fucked_cmd}}`'").format(alias_name)

View File

@ -18,6 +18,7 @@ class Zsh(Generic):
{name} () {{
TF_PYTHONIOENCODING=$PYTHONIOENCODING;
export TF_SHELL=zsh;
export TF_STATUS=$?;
export TF_ALIAS={name};
TF_SHELL_ALIASES=$(alias);
export TF_SHELL_ALIASES;