2015-05-20 17:55:48 +02:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.man import match, get_new_command
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-05-20 17:55:48 +02:00
|
|
|
|
2015-05-20 23:53:08 -03:00
|
|
|
|
2015-05-20 17:55:48 +02:00
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('man read', ''),
|
|
|
|
Command('man 2 read', ''),
|
|
|
|
Command('man 3 read', ''),
|
|
|
|
Command('man -s2 read', ''),
|
|
|
|
Command('man -s3 read', ''),
|
|
|
|
Command('man -s 2 read', ''),
|
|
|
|
Command('man -s 3 read', '')])
|
2015-05-20 17:55:48 +02:00
|
|
|
def test_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert match(command)
|
2015-05-20 17:55:48 +02:00
|
|
|
|
|
|
|
|
2015-05-20 23:53:08 -03:00
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('man', ''),
|
|
|
|
Command('man ', '')])
|
2015-05-20 23:53:08 -03:00
|
|
|
def test_not_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert not match(command)
|
2015-05-20 23:53:08 -03:00
|
|
|
|
|
|
|
|
2015-05-20 17:55:48 +02:00
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command('man read', ''), ['man 3 read', 'man 2 read', 'read --help']),
|
|
|
|
(Command('man missing', "No manual entry for missing\n"), ['missing --help']),
|
|
|
|
(Command('man 2 read', ''), 'man 3 read'),
|
|
|
|
(Command('man 3 read', ''), 'man 2 read'),
|
|
|
|
(Command('man -s2 read', ''), 'man -s3 read'),
|
|
|
|
(Command('man -s3 read', ''), 'man -s2 read'),
|
|
|
|
(Command('man -s 2 read', ''), 'man -s 3 read'),
|
|
|
|
(Command('man -s 3 read', ''), 'man -s 2 read')])
|
2015-05-20 17:55:48 +02:00
|
|
|
def test_get_new_command(command, new_command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert get_new_command(command) == new_command
|