mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +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 thefuck.rules.cp_omitting_directory import match, get_new_command
|
||||||
|
from tests.utils import Command
|
||||||
|
|
||||||
|
|
||||||
def test_match():
|
@pytest.mark.parametrize('script, stderr', [
|
||||||
assert match(Mock(script='cp dir', stderr="cp: omitting directory 'dir'"),
|
('cp dir', 'cp: dor: is a directory'),
|
||||||
None)
|
('cp dir', "cp: omitting directory 'dir'")])
|
||||||
assert not match(Mock(script='some dir',
|
def test_match(script, stderr):
|
||||||
stderr="cp: omitting directory 'dir'"), None)
|
assert match(Command(script, stderr=stderr), None)
|
||||||
assert not match(Mock(script='cp dir', 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():
|
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
|
@sudo_support
|
||||||
def match(command, settings):
|
def match(command, settings):
|
||||||
|
stderr = command.stderr.lower()
|
||||||
return command.script.startswith('cp ') \
|
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
|
@sudo_support
|
||||||
|
Loading…
x
Reference in New Issue
Block a user