5555 remove_functions_from_generated_tests ,
5656)
5757from codeflash .code_utils .env_utils import get_pr_number
58- from codeflash .code_utils .formatter import format_code , sort_imports
58+ from codeflash .code_utils .formatter import format_code , format_generated_code , sort_imports
5959from codeflash .code_utils .git_utils import git_root_dir
6060from codeflash .code_utils .instrument_existing_tests import inject_profiling_into_existing_test
6161from codeflash .code_utils .line_profile_utils import add_decorator_imports
@@ -1401,6 +1401,9 @@ def process_review(
14011401 generated_tests = remove_functions_from_generated_tests (
14021402 generated_tests = generated_tests , test_functions_to_remove = test_functions_to_remove
14031403 )
1404+ map_gen_test_file_to_no_of_tests = original_code_baseline .behavior_test_results .file_to_no_of_tests (
1405+ test_functions_to_remove
1406+ )
14041407
14051408 original_runtime_by_test = original_code_baseline .benchmarking_test_results .usable_runtime_data_by_test_case ()
14061409 optimized_runtime_by_test = (
@@ -1413,11 +1416,16 @@ def process_review(
14131416
14141417 generated_tests_str = ""
14151418 for test in generated_tests .generated_tests :
1416- generated_tests_str += f"```python\n { test .generated_original_test_source } \n ```"
1417- generated_tests_str += "\n \n "
1419+ if map_gen_test_file_to_no_of_tests [test .behavior_file_path ] > 0 :
1420+ formatted_generated_test = format_generated_code (
1421+ test .generated_original_test_source , self .args .formatter_cmds
1422+ )
1423+ generated_tests_str += f"```python\n { formatted_generated_test } \n ```"
1424+ generated_tests_str += "\n \n "
14181425
14191426 if concolic_test_str :
1420- generated_tests_str += f"```python\n { concolic_test_str } \n ```\n \n "
1427+ formatted_generated_test = format_generated_code (concolic_test_str , self .args .formatter_cmds )
1428+ generated_tests_str += f"```python\n { formatted_generated_test } \n ```\n \n "
14211429
14221430 existing_tests , replay_tests , concolic_tests = existing_tests_source_for (
14231431 self .function_to_optimize .qualified_name_with_modules_from_root (self .project_root ),
@@ -1533,7 +1541,7 @@ def process_review(
15331541 trace_id = self .function_trace_id , is_optimization_found = best_optimization is not None
15341542 )
15351543
1536- # If worktree mode, do not revert code and helpers,, otherwise we would have an empty diff when writing the patch in the lsp
1544+ # If worktree mode, do not revert code and helpers, otherwise we would have an empty diff when writing the patch in the lsp
15371545 if self .args .worktree :
15381546 return
15391547
0 commit comments