import pytest from thefuck.rules.git_fix_stash import match, get_new_command from tests.utils import Command git_stash_err = ''' usage: git stash list [] or: git stash show [] or: git stash drop [-q|--quiet] [] or: git stash ( pop | apply ) [--index] [-q|--quiet] [] or: git stash branch [] or: git stash [save [--patch] [-k|--[no-]keep-index] [-q|--quiet] \t\t [-u|--include-untracked] [-a|--all] []] or: git stash clear ''' @pytest.mark.parametrize('wrong', [ 'git stash opp', 'git stash Some message', 'git stash saev Some message']) def test_match(wrong): assert match(Command(wrong, stderr=git_stash_err), None) @pytest.mark.parametrize('wrong,fixed', [ ('git stash opp', 'git stash pop'), ('git stash Some message', 'git stash save Some message'), ('git stash saev Some message', 'git stash save Some message')]) def test_get_new_command(wrong, fixed): assert get_new_command(Command(wrong, stderr=git_stash_err), None) == fixed