File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -8,5 +8,5 @@ def make_executable_command(command: str) -> str:
88 if command .endswith ('`' ):
99 command = command [:- 1 ]
1010 command = command .strip ()
11- command = command .split ('User: ' )[0 ]
11+ command = command .split ('User: ' )[- 1 ]
1212 return command
Original file line number Diff line number Diff line change 1+ from aishell .utils import make_executable_command
2+
3+
4+ def test_make_executable_command_starts_and_ends_with_newline ():
5+ command = '\n ls -l\n '
6+ expected_output = 'ls -l'
7+ assert make_executable_command (command ) == expected_output
8+
9+
10+ def test_make_executable_command_starts_and_ends_with_backtick ():
11+ command = '`python my_script.py`\n '
12+ expected_output = 'python my_script.py'
13+ assert make_executable_command (command ) == expected_output
14+
15+
16+ def test_make_executable_command_starts_with_user ():
17+ command = 'User: cd ..'
18+ expected_output = 'cd ..'
19+ assert make_executable_command (command ) == expected_output
20+
21+
22+ def test_make_executable_command_no_leading_or_trailing_whitespace ():
23+ command = 'git clone https://github.com/my_repo.git'
24+ expected_output = 'git clone https://github.com/my_repo.git'
25+ assert make_executable_command (command ) == expected_output
You can’t perform that action at this time.
0 commit comments