1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-04-18 08:40:44 +01:00
thefuck/tests/rules/test_remove_shell_prompt_literal.py
Boon Wenjie d7e2d4e3c6 Add rule to remove shell prompt literals $
Rule added to handle cases where the $ symbol is used in the command,
this usually happens when the command is copy pasted from a
documentation that includes the shell prompt symbol in the code blocks.
2019-10-28 17:30:05 +00:00

33 lines
853 B
Python

import pytest
from thefuck.rules.remove_shell_prompt_literal import match, get_new_command
from thefuck.types import Command
@pytest.mark.parametrize('command',
[
Command('$ cd newdir', '$: command not found'),
Command(' $ cd newdir', '$: command not found'),
])
def test_match(command):
assert match(command)
@pytest.mark.parametrize('command',
[
Command('$', ''),
Command('$?', ''),
Command(' $?', ''),
Command('', ''),
])
def test_not_match(command):
assert not match(command)
@pytest.mark.parametrize('command, new_command',
[
(Command('$ cd newdir', ''), 'cd newdir'),
(Command('$ python3 -m virtualenv env', ''), 'python3 -m virtualenv env'),
])
def test_get_new_command(command, new_command):
assert get_new_command(command) == new_command