Refactor commit_cases.py and workflow_test.py

This commit is contained in:
bobo.yang 2023-12-14 10:28:08 +08:00
parent aee87ad495
commit 16faea4e78
2 changed files with 4 additions and 8 deletions

View File

@ -174,9 +174,6 @@ def git_repo_case(git_url, expected_commit_message):
current_directory = ''
code_diff = ''
def title():
return f'commit {git_url}'
def input_mock(output):
nonlocal stdout_result
nonlocal ui_processed
@ -239,6 +236,7 @@ def git_repo_case(git_url, expected_commit_message):
return {
'input': '/commit',
'title': f'commit {git_url}',
'input_mock': input_mock,
'assert': assert_result,
'setup': setup,
@ -261,10 +259,7 @@ def case1():
)]
current_input_index = 0
last_commit_id = None
def title():
return 'commit local repo'
def input_mock(output):
nonlocal current_input_index
nonlocal input_pattern
@ -290,6 +285,7 @@ def case1():
return {
'input': '/commit',
'title': 'commit local repo',
'input_mock': input_mock,
'assert': assert_result,
'setup': setup,

View File

@ -70,7 +70,7 @@ def run_commit_tests():
exit_code = run_devchat_command(model, case['input'], case['input_mock'])
case_result = case['assert']()
case['teardown']()
case_results.append((case['title'](), case_result and exit_code == 0))
case_results.append((case['title'], case_result and exit_code == 0))
else:
print('Error: test case setup failed!')
case_results.append((case['title'](), 'Error: test case setup failed!'))