Testing Shell Command Correction Logic in TheFuck
This test suite validates the functionality of the ‘ls_all’ rule in TheFuck project, which automatically corrects ‘ls’ commands by adding the -A flag to show hidden files. The tests ensure proper command matching and transformation for improved shell usage.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
nvbn/thefuck
tests/rules/test_ls_all.py
from thefuck.rules.ls_all import match, get_new_command
from thefuck.types import Command
def test_match():
assert match(Command('ls', ''))
assert not match(Command('ls', 'file.py
'))
def test_get_new_command():
assert get_new_command(Command('ls empty_dir', '')) == 'ls -A empty_dir'
assert get_new_command(Command('ls', '')) == 'ls -A'