mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-20 20:09:07 +00:00
#289: Add is a directory
pattern to cp_omitting_directory
rule
This commit is contained in:
parent
464f86eccf
commit
934099fe9e
@ -1,14 +1,22 @@
|
||||
from mock import Mock
|
||||
import pytest
|
||||
from thefuck.rules.cp_omitting_directory import match, get_new_command
|
||||
from tests.utils import Command
|
||||
|
||||
|
||||
def test_match():
|
||||
assert match(Mock(script='cp dir', stderr="cp: omitting directory 'dir'"),
|
||||
None)
|
||||
assert not match(Mock(script='some dir',
|
||||
stderr="cp: omitting directory 'dir'"), None)
|
||||
assert not match(Mock(script='cp dir', stderr=""), None)
|
||||
@pytest.mark.parametrize('script, stderr', [
|
||||
('cp dir', 'cp: dor: is a directory'),
|
||||
('cp dir', "cp: omitting directory 'dir'")])
|
||||
def test_match(script, stderr):
|
||||
assert match(Command(script, stderr=stderr), None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('script, stderr', [
|
||||
('some dir', 'cp: dor: is a directory'),
|
||||
('some dir', "cp: omitting directory 'dir'"),
|
||||
('cp dir', '')])
|
||||
def test_not_match(script, stderr):
|
||||
assert not match(Command(script, stderr=stderr), None)
|
||||
|
||||
|
||||
def test_get_new_command():
|
||||
assert get_new_command(Mock(script='cp dir'), None) == 'cp -a dir'
|
||||
assert get_new_command(Command(script='cp dir'), None) == 'cp -a dir'
|
||||
|
@ -4,8 +4,9 @@ from thefuck.utils import sudo_support
|
||||
|
||||
@sudo_support
|
||||
def match(command, settings):
|
||||
stderr = command.stderr.lower()
|
||||
return command.script.startswith('cp ') \
|
||||
and 'cp: omitting directory' in command.stderr.lower()
|
||||
and ('omitting directory' in stderr or 'is a directory' in stderr)
|
||||
|
||||
|
||||
@sudo_support
|
||||
|
Loading…
x
Reference in New Issue
Block a user