Skip to content

Commit b64e9b3

Browse files
committed
Add tests
1 parent 3aad968 commit b64e9b3

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

aishell/utils/make_executable_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

aishell/utils/test/__init__.py

Whitespace-only changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from aishell.utils import make_executable_command
2+
3+
4+
def test_make_executable_command_starts_and_ends_with_newline():
5+
command = '\nls -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

0 commit comments

Comments
 (0)