1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 02:41:10 +01:00
thefuck/tests/rules/test_rm_dir.py

32 lines
918 B
Python
Raw Normal View History

import pytest
from thefuck.rules.rm_dir import match, get_new_command
from tests.utils import Command
@pytest.mark.parametrize('command', [
Command('rm foo', stderr='rm: foo: is a directory'),
2015-08-21 15:48:54 +01:00
Command('rm foo', stderr='rm: foo: Is a directory'),
Command('hdfs dfs -rm foo', stderr='rm: `foo`: Is a directory'),
2015-11-15 17:02:37 +00:00
Command('./bin/hdfs dfs -rm foo', stderr='rm: `foo`: Is a directory'),
])
def test_match(command):
assert match(command)
@pytest.mark.parametrize('command', [
2015-11-15 17:02:37 +00:00
Command('rm foo'),
2015-08-21 15:48:54 +01:00
Command('hdfs dfs -rm foo'),
2015-11-15 17:02:37 +00:00
Command('./bin/hdfs dfs -rm foo'),
Command(),
])
def test_not_match(command):
assert not match(command)
2015-08-21 15:48:54 +01:00
@pytest.mark.parametrize('command, new_command', [
(Command('rm foo'), 'rm -rf foo'),
2015-11-15 17:02:37 +00:00
(Command('hdfs dfs -rm foo'), 'hdfs dfs -rm -r foo'),
])
2015-08-21 15:48:54 +01:00
def test_get_new_command(command, new_command):
assert get_new_command(command) == new_command