1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-19 04:21:14 +00:00
thefuck/tests/rules/test_no_such_file.py

28 lines
990 B
Python
Raw Normal View History

2015-05-15 18:03:33 +02:00
import pytest
from thefuck.rules.no_such_file import match, get_new_command
from thefuck.types import Command
2015-05-15 18:03:33 +02:00
@pytest.mark.parametrize('command', [
Command('mv foo bar/foo', "mv: cannot move 'foo' to 'bar/foo': No such file or directory"),
Command('mv foo bar/', "mv: cannot move 'foo' to 'bar/': No such file or directory"),
2015-11-15 18:02:37 +01:00
])
2015-05-15 18:03:33 +02:00
def test_match(command):
assert match(command)
2015-05-15 18:03:33 +02:00
@pytest.mark.parametrize('command', [
Command('mv foo bar/', ""),
Command('mv foo bar/foo', "mv: permission denied"),
2015-11-15 18:02:37 +01:00
])
def test_not_match(command):
assert not match(command)
2015-05-15 18:03:33 +02:00
@pytest.mark.parametrize('command, new_command', [
(Command('mv foo bar/foo', "mv: cannot move 'foo' to 'bar/foo': No such file or directory"), 'mkdir -p bar && mv foo bar/foo'),
(Command('mv foo bar/', "mv: cannot move 'foo' to 'bar/': No such file or directory"), 'mkdir -p bar && mv foo bar/'),
2015-11-15 18:02:37 +01:00
])
2015-05-15 18:03:33 +02:00
def test_get_new_command(command, new_command):
assert get_new_command(command) == new_command