fix: return display-version tests as generated_tests in testgen response (#2477)
## Summary - The `/testgen` response's `generated_tests` field contained the assert-removed version with `codeflash_output` assignments - When the CLI's testgen review fell back to this field (instead of `raw_generated_tests`), the review LLM flagged every test as a "no-op assignment" - Now returns the display version (asserts kept, no instrumentation) as `generated_tests`, matching what the repair endpoint already does - Also applies isort to the display source for consistency
This commit is contained in:
parent
42b8eed7b4
commit
d74da02e57
1 changed files with 8 additions and 1 deletions
|
|
@ -309,6 +309,13 @@ async def generate_regression_tests_from_function(
|
|||
generated_test_source = sorted_generated_tests
|
||||
except Exception: # noqa: BLE001
|
||||
sentry_sdk.capture_message("isort caused a syntax error in testgen; returning un-sorted code.")
|
||||
|
||||
sorted_display_source = safe_isort(raw_display_source)
|
||||
try:
|
||||
parse_module_to_cst(sorted_display_source)
|
||||
raw_display_source = sorted_display_source
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
tree = ast.parse(generated_test_source, feature_version=python_version[:2])
|
||||
if not has_test_functions(tree): # sanity check, after all the processing somehow no test functions
|
||||
msg = f"No test functions were found in the generated test code. trace_id={trace_id}"
|
||||
|
|
@ -420,7 +427,7 @@ async def testgen_python(
|
|||
)
|
||||
|
||||
return 200, TestGenResponseSchema(
|
||||
generated_tests=generated_test_source,
|
||||
generated_tests=raw_display_source,
|
||||
instrumented_behavior_tests=instrumented_behavior_tests,
|
||||
instrumented_perf_tests=instrumented_perf_tests,
|
||||
raw_generated_tests=raw_display_source,
|
||||
|
|
|
|||
Loading…
Reference in a new issue