1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-10-31 07:04:12 +00:00

Merge branch 'master' into 682-instant-fuck-mode

This commit is contained in:
Vladimir Iakovlev
2017-09-02 09:31:24 +02:00
11 changed files with 137 additions and 102 deletions

View File

View File

@@ -0,0 +1,26 @@
import pytest
from mock import Mock
from thefuck.entrypoints.fix_command import _get_raw_command
class TestGetRawCommand(object):
def test_from_force_command_argument(self):
known_args = Mock(force_command=['git', 'brunch'])
assert _get_raw_command(known_args) == ['git', 'brunch']
def test_from_command_argument(self, os_environ):
os_environ['TF_HISTORY'] = None
known_args = Mock(force_command=None,
command=['sl'])
assert _get_raw_command(known_args) == ['sl']
@pytest.mark.parametrize('history, result', [
('git br', 'git br'),
('git br\nfcuk', 'git br'),
('git br\nfcuk\nls', 'ls'),
('git br\nfcuk\nls\nfuk', 'ls')])
def test_from_history(self, os_environ, history, result):
os_environ['TF_HISTORY'] = history
known_args = Mock(force_command=None,
command=None)
assert _get_raw_command(known_args) == [result]

View File

@@ -3,13 +3,13 @@ import json
from six import StringIO
from mock import MagicMock
from thefuck.shells.generic import ShellConfiguration
from thefuck.not_configured import main
from thefuck.entrypoints.not_configured import main
@pytest.fixture(autouse=True)
def usage_tracker(mocker):
return mocker.patch(
'thefuck.not_configured._get_not_configured_usage_tracker_path',
'thefuck.entrypoints.not_configured._get_not_configured_usage_tracker_path',
new_callable=MagicMock)
@@ -44,13 +44,13 @@ def _change_tracker(usage_tracker_io, pid):
@pytest.fixture(autouse=True)
def shell_pid(mocker):
return mocker.patch('thefuck.not_configured._get_shell_pid',
return mocker.patch('thefuck.entrypoints.not_configured._get_shell_pid',
new_callable=MagicMock)
@pytest.fixture(autouse=True)
def shell(mocker):
shell = mocker.patch('thefuck.not_configured.shell',
shell = mocker.patch('thefuck.entrypoints.not_configured.shell',
new_callable=MagicMock)
shell.get_history.return_value = []
shell.how_to_configure.return_value = ShellConfiguration(
@@ -63,7 +63,7 @@ def shell(mocker):
@pytest.fixture(autouse=True)
def shell_config(mocker):
path_mock = mocker.patch('thefuck.not_configured.Path',
path_mock = mocker.patch('thefuck.entrypoints.not_configured.Path',
new_callable=MagicMock)
return path_mock.return_value \
.expanduser.return_value \
@@ -73,7 +73,7 @@ def shell_config(mocker):
@pytest.fixture(autouse=True)
def logs(mocker):
return mocker.patch('thefuck.not_configured.logs',
return mocker.patch('thefuck.entrypoints.not_configured.logs',
new_callable=MagicMock)