diff --git a/tests/rules/test_rm_root.py b/tests/rules/test_rm_root.py new file mode 100644 index 00000000..003cb800 --- /dev/null +++ b/tests/rules/test_rm_root.py @@ -0,0 +1,18 @@ +from mock import Mock +from thefuck.rules.rm_root import match, get_new_command + + +def test_match(): + assert match(Mock(script='rm -rf /', + stderr='add --no-preserve-root'), None) + assert not match(Mock(script='ls', + stderr='add --no-preserve-root'), None) + assert not match(Mock(script='rm --no-preserve-root /', + stderr='add --no-preserve-root'), None) + assert not match(Mock(script='rm -rf /', + stderr=''), None) + + +def test_get_new_command(): + assert get_new_command(Mock(script='rm -rf /'), None) \ + == 'rm -rf / --no-preserve-root' diff --git a/thefuck/main.py b/thefuck/main.py index 32c1c7c8..a6c24ee5 100644 --- a/thefuck/main.py +++ b/thefuck/main.py @@ -153,8 +153,7 @@ def main(): logs.failed("Can't fuck twice", settings) return - rules = list(get_rules(user_dir, settings)) - sys.stderr.write(str([r.name for r in rules]) + '\n') + rules = get_rules(user_dir, settings) matched_rule = get_matched_rule(command, rules, settings) if matched_rule: run_rule(matched_rule, command, settings) diff --git a/thefuck/rules/rm_root.py b/thefuck/rules/rm_root.py index fc75332d..d07543b3 100644 --- a/thefuck/rules/rm_root.py +++ b/thefuck/rules/rm_root.py @@ -8,4 +8,4 @@ def match(command, settings): def get_new_command(command, settings): - return '{} --no-preserve-root'.format(command.script) + return u'{} --no-preserve-root'.format(command.script)