<commit_before>from thefuck.rules.git_flag_after_filename import match, get_new_command
from tests.utils import Command


def test_match():
    assert match(Command('git log README.md -p', stderr="fatal: bad flag '-p' used after filename"))
    assert match(Command('git log README.md -p CONTRIBUTING.md', stderr="fatal: bad flag '-p' used after filename"))
    assert match(Command('git log -p README.md --name-only', stderr="fatal: bad flag '--name-only' used after filename"))
    assert not match(Command('git log README.md'))
    assert not match(Command('git log -p README.md'))


def test_get_new_command():
    assert get_new_command(Command('git log README.md -p', stderr="fatal: bad flag '-p' used after filename"))\
        == "git log -p README.md"
    assert get_new_command(Command('git log README.md -p CONTRIBUTING.md', stderr="fatal: bad flag '-p' used after filename"))\
        == "git log -p README.md CONTRIBUTING.md"
    assert get_new_command(Command('git log -p README.md --name-only', stderr="fatal: bad flag '--name-only' used after filename"))\
        == "git log -p --name-only README.md"<commit_msg>test_git_flag_after_filename.py: dedupe test commands<commit_after>from thefuck.rules.git_flag_after_filename import match, get_new_command
from tests.utils import Command

command1 = Command('git log README.md -p',
                   stderr="fatal: bad flag '-p' used after filename")
command2 = Command('git log README.md -p CONTRIBUTING.md',
                   stderr="fatal: bad flag '-p' used after filename")
command3 = Command('git log -p README.md --name-only',
                   stderr="fatal: bad flag '--name-only' used after filename")


def test_match():
    assert match(command1)
    assert match(command2)
    assert match(command3)
    assert not match(Command('git log README.md'))
    assert not match(Command('git log -p README.md'))


def test_get_new_command():
    assert get_new_command(command1) == "git log -p README.md"
    assert get_new_command(command2) == "git log -p README.md CONTRIBUTING.md"
    assert get_new_command(command3) == "git log -p --name-only README.md"
{'fraction_non_alphanumeric': 0.1295774647887324, 'fraction_numerical': 0.004225352112676056, 'mean_word_length': 3.7566964285714284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3390207', 'n_tokens_mistral': 682, 'n_tokens_neox': 656, 'n_words': 204}