Testing Directory Navigation Error Detection in TheFuck
This test suite validates the cd_correction rule functionality in TheFuck, a command-line tool that corrects mistyped console commands. The tests specifically focus on verifying the pattern matching behavior for invalid directory navigation attempts.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
nvbn/thefuck
tests/rules/test_cd_correction.py
import pytest
from thefuck.rules.cd_correction import match
from thefuck.types import Command
@pytest.mark.parametrize('command', [
Command('cd foo', 'cd: foo: No such file or directory'),
Command('cd foo/bar/baz',
'cd: foo: No such file or directory'),
Command('cd foo/bar/baz', 'cd: can\'t cd to foo/bar/baz'),
Command('cd /foo/bar/', 'cd: The directory "/foo/bar/" does not exist')])
def test_match(command):
assert match(command)
@pytest.mark.parametrize('command', [
Command('cd foo', ''), Command('', '')])
def test_not_match(command):
assert not match(command)
# Note that get_new_command uses local filesystem, so not testing it here.
# Instead, see the functional test `functional.test_cd_correction`