44
55
66@pytest .fixture
7- def pip_unknown_cmd ():
8- return '''ERROR: unknown command "instatl" - maybe you meant "install "'''
7+ def pip_unknown_cmd_without_recommend ():
8+ return '''ERROR: unknown command "i "'''
99
1010
1111@pytest .fixture
12- def pip_unknown_cmd_without_recommend ():
13- return '''ERROR: unknown command "i"'''
12+ def broken ():
13+ return 'instatl'
14+
15+
16+ @pytest .fixture
17+ def suggested ():
18+ return 'install'
19+
20+
21+ @pytest .fixture
22+ def pip_unknown_cmd (broken , suggested ):
23+ return 'ERROR: unknown command "{}" - maybe you meant "{}"' .format (broken , suggested )
1424
1525
1626def test_match (pip_unknown_cmd , pip_unknown_cmd_without_recommend ):
@@ -19,6 +29,9 @@ def test_match(pip_unknown_cmd, pip_unknown_cmd_without_recommend):
1929 pip_unknown_cmd_without_recommend ))
2030
2131
22- def test_get_new_command (pip_unknown_cmd ):
23- assert get_new_command (Command ('pip instatl' ,
24- pip_unknown_cmd )) == 'pip install'
32+ @pytest .mark .parametrize ('script, broken, suggested, new_cmd' , [
33+ ('pip un+install thefuck' , 'un+install' , 'uninstall' , 'pip uninstall thefuck' ),
34+ ('pip instatl' , 'instatl' , 'install' , 'pip install' )])
35+ def test_get_new_command (script , new_cmd , pip_unknown_cmd ):
36+ assert get_new_command (Command (script ,
37+ pip_unknown_cmd )) == new_cmd
0 commit comments