Remove obscure SortedCorrectedCommandsSequence
This commit is contained in:
+13
-16
@@ -1,10 +1,9 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from mock import Mock
|
||||
import pytest
|
||||
from itertools import islice
|
||||
from thefuck import ui
|
||||
from thefuck.types import CorrectedCommand, SortedCorrectedCommandsSequence
|
||||
from thefuck.types import CorrectedCommand
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -41,7 +40,7 @@ def test_read_actions(patch_getch):
|
||||
|
||||
|
||||
def test_command_selector():
|
||||
selector = ui.CommandSelector([1, 2, 3])
|
||||
selector = ui.CommandSelector(iter([1, 2, 3]))
|
||||
assert selector.value == 1
|
||||
selector.next()
|
||||
assert selector.value == 2
|
||||
@@ -57,51 +56,49 @@ def test_command_selector():
|
||||
class TestSelectCommand(object):
|
||||
@pytest.fixture
|
||||
def commands_with_side_effect(self):
|
||||
return SortedCorrectedCommandsSequence(
|
||||
iter([CorrectedCommand('ls', lambda *_: None, 100),
|
||||
CorrectedCommand('cd', lambda *_: None, 100)]))
|
||||
return [CorrectedCommand('ls', lambda *_: None, 100),
|
||||
CorrectedCommand('cd', lambda *_: None, 100)]
|
||||
|
||||
@pytest.fixture
|
||||
def commands(self):
|
||||
return SortedCorrectedCommandsSequence(
|
||||
iter([CorrectedCommand('ls', None, 100),
|
||||
CorrectedCommand('cd', None, 100)]))
|
||||
return [CorrectedCommand('ls', None, 100),
|
||||
CorrectedCommand('cd', None, 100)]
|
||||
|
||||
def test_without_commands(self, capsys):
|
||||
assert ui.select_command([]) is None
|
||||
assert ui.select_command(iter([])) is None
|
||||
assert capsys.readouterr() == ('', 'No fucks given\n')
|
||||
|
||||
def test_without_confirmation(self, capsys, commands, settings):
|
||||
settings.require_confirmation = False
|
||||
assert ui.select_command(commands) == commands[0]
|
||||
assert ui.select_command(iter(commands)) == commands[0]
|
||||
assert capsys.readouterr() == ('', 'ls\n')
|
||||
|
||||
def test_without_confirmation_with_side_effects(
|
||||
self, capsys, commands_with_side_effect, settings):
|
||||
settings.require_confirmation = False
|
||||
assert ui.select_command(commands_with_side_effect) \
|
||||
assert ui.select_command(iter(commands_with_side_effect)) \
|
||||
== commands_with_side_effect[0]
|
||||
assert capsys.readouterr() == ('', 'ls (+side effect)\n')
|
||||
|
||||
def test_with_confirmation(self, capsys, patch_getch, commands):
|
||||
patch_getch(['\n'])
|
||||
assert ui.select_command(commands) == commands[0]
|
||||
assert ui.select_command(iter(commands)) == commands[0]
|
||||
assert capsys.readouterr() == ('', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\n')
|
||||
|
||||
def test_with_confirmation_abort(self, capsys, patch_getch, commands):
|
||||
patch_getch([KeyboardInterrupt])
|
||||
assert ui.select_command(commands) is None
|
||||
assert ui.select_command(iter(commands)) is None
|
||||
assert capsys.readouterr() == ('', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\nAborted\n')
|
||||
|
||||
def test_with_confirmation_with_side_effct(self, capsys, patch_getch,
|
||||
commands_with_side_effect):
|
||||
patch_getch(['\n'])
|
||||
assert ui.select_command(commands_with_side_effect)\
|
||||
assert ui.select_command(iter(commands_with_side_effect))\
|
||||
== commands_with_side_effect[0]
|
||||
assert capsys.readouterr() == ('', u'\x1b[1K\rls (+side effect) [enter/↑/↓/ctrl+c]\n')
|
||||
|
||||
def test_with_confirmation_select_second(self, capsys, patch_getch, commands):
|
||||
patch_getch(['\x1b', '[', 'B', '\n'])
|
||||
assert ui.select_command(commands) == commands[1]
|
||||
assert ui.select_command(iter(commands)) == commands[1]
|
||||
assert capsys.readouterr() == (
|
||||
'', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\x1b[1K\rcd [enter/↑/↓/ctrl+c]\n')
|
||||
|
||||
Reference in New Issue
Block a user