Testing Directory Navigation Command Correction in TheFuck
This test suite validates the functionality of the ‘cd_cs’ rule in TheFuck project, which handles the common typo of using ‘cs’ instead of ‘cd’ for directory navigation. The tests ensure proper command correction behavior and error handling.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
nvbn/thefuck
tests/rules/test_cd_cs.py
from thefuck.rules.cd_cs import match, get_new_command
from thefuck.types import Command
def test_match():
assert match(Command('cs', 'cs: command not found'))
assert match(Command('cs /etc/', 'cs: command not found'))
def test_get_new_command():
assert get_new_command(Command('cs /etc/', 'cs: command not found')) == 'cd /etc/'