Testing Git Command Correction Logic in thefuck
This test suite validates the git_pull_clone rule functionality in thefuck, which handles the scenario of attempting a git pull in a non-repository directory. The tests ensure proper error detection and command correction behavior.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
nvbn/thefuck
tests/rules/test_git_pull_clone.py
import pytest
from thefuck.rules.git_pull_clone import match, get_new_command
from thefuck.types import Command
git_err = '''
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
'''
@pytest.mark.parametrize('command', [
Command('git pull [email protected]:mcarton/thefuck.git', git_err)])
def test_match(command):
assert match(command)
@pytest.mark.parametrize('command, output', [
(Command('git pull [email protected]:mcarton/thefuck.git', git_err), 'git clone [email protected]:mcarton/thefuck.git')])
def test_get_new_command(command, output):
assert get_new_command(command) == output