2015-04-25 02:13:57 +01:00
|
|
|
|
# -*- encoding: utf-8 -*-
|
|
|
|
|
|
2015-04-23 07:35:50 +01:00
|
|
|
|
from thefuck.rules.fix_alt_space import match, get_new_command
|
2017-08-31 16:58:56 +01:00
|
|
|
|
from thefuck.types import Command
|
2015-04-23 07:35:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_match():
|
2015-04-25 01:35:26 +01:00
|
|
|
|
"""The character before 'grep' is Alt+Space, which happens frequently
|
|
|
|
|
on the Mac when typing the pipe character (Alt+7), and holding the Alt
|
|
|
|
|
key pressed for longer than necessary.
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
assert match(Command(u'ps -ef | grep foo',
|
2017-08-31 16:58:56 +01:00
|
|
|
|
u'-bash: grep: command not found'))
|
|
|
|
|
assert not match(Command('ps -ef | grep foo', ''))
|
|
|
|
|
assert not match(Command('', ''))
|
2015-04-23 07:35:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_new_command():
|
|
|
|
|
""" Replace the Alt+Space character by a simple space """
|
2017-08-31 16:58:56 +01:00
|
|
|
|
assert (get_new_command(Command(u'ps -ef | grep foo', ''))
|
2016-10-06 20:16:43 +01:00
|
|
|
|
== 'ps -ef | grep foo')
|