1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-10-08 12:53:58 +01:00

#N/A: Add a new rule to create directory on cp or mv

This commit is contained in:
Caplinja
2020-03-01 00:07:54 -06:00
committed by Pablo Aguiar
parent 444908ce1c
commit 88db57b4b1
3 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import pytest
from thefuck.rules.cp_create_destination import match, get_new_command
from thefuck.types import Command
@pytest.mark.parametrize(
"script, output",
[("cp", "cp: directory foo does not exist\n"), ("mv", "No such file or directory")],
)
def test_match(script, output):
assert match(Command(script, output))
@pytest.mark.parametrize(
"script, output", [("cp", ""), ("mv", ""), ("ls", "No such file or directory")]
)
def test_not_match(script, output):
assert not match(Command(script, output))
@pytest.mark.parametrize(
"script, output, new_command",
[
("cp foo bar/", "cp: directory foo does not exist\n", "mkdir -p bar/ && cp foo bar/"),
("mv foo bar/", "No such file or directory", "mkdir -p bar/ && mv foo bar/"),
("cp foo bar/baz/", "cp: directory foo does not exist\n", "mkdir -p bar/baz/ && cp foo bar/baz/"),
],
)
def test_get_new_command(script, output, new_command):
assert get_new_command(Command(script, output)) == new_command