1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-19 12:24:29 +00:00
thefuck/tests/rules/test_fix_alt_space.py
Nils Winkler f1cce413b3 Added rule for fixing Alt+Space character
Happens on the Mac a lot when typing a pipe character (Alt+7), and
keeping the Alt key pressed down for a bit too long, so instead of
Space, you're typing Alt+Space. This rule replaces the Alt+Space with a
simple Space character.

$ ps -ef | grep foo
-bash:  grep: command not found
$ fuck
ps -ef | grep foo
2015-04-23 15:19:30 +02:00

19 lines
739 B
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- encoding: utf-8 -*-
from thefuck.types import Command
from thefuck.rules.fix_alt_space import match, get_new_command
def test_match():
""" 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', '', u'-bash:  grep: command not found'), None)
assert not match(Command('ps -ef | grep foo', '', ''), None)
assert not match(Command('', '', ''), None)
def test_get_new_command():
""" Replace the Alt+Space character by a simple space """
assert get_new_command(Command(u'ps -ef | grep foo', '', ''), None) == 'ps -ef | grep foo'