|
21 | 21 | ) |
22 | 22 | from codeflash.code_utils.concolic_utils import clean_concolic_tests |
23 | 23 | from codeflash.code_utils.coverage_utils import extract_dependent_function, generate_candidates, prepare_coverage_files |
| 24 | +from codeflash.models.models import CodeStringsMarkdown |
24 | 25 |
|
25 | 26 |
|
26 | 27 | @pytest.fixture |
@@ -382,69 +383,76 @@ def mock_code_context(): |
382 | 383 | def test_extract_dependent_function_sync_and_async(mock_code_context): |
383 | 384 | """Test extract_dependent_function with both sync and async functions.""" |
384 | 385 | # Test sync function extraction |
385 | | - mock_code_context.testgen_context_code = """ |
| 386 | + mock_code_context.testgen_context = CodeStringsMarkdown.parse_markdown_code("""```python:file.py |
386 | 387 | def main_function(): |
387 | 388 | pass |
388 | 389 |
|
389 | 390 | def helper_function(): |
390 | 391 | pass |
391 | | -""" |
| 392 | +``` |
| 393 | +""") |
392 | 394 | assert extract_dependent_function("main_function", mock_code_context) == "helper_function" |
393 | 395 |
|
394 | 396 | # Test async function extraction |
395 | | - mock_code_context.testgen_context_code = """ |
| 397 | + mock_code_context.testgen_context = CodeStringsMarkdown.parse_markdown_code("""```python:file.py |
396 | 398 | def main_function(): |
397 | 399 | pass |
398 | 400 |
|
399 | 401 | async def async_helper_function(): |
400 | 402 | pass |
401 | | -""" |
| 403 | +``` |
| 404 | +""") |
| 405 | + |
402 | 406 | assert extract_dependent_function("main_function", mock_code_context) == "async_helper_function" |
403 | 407 |
|
404 | 408 |
|
405 | 409 | def test_extract_dependent_function_edge_cases(mock_code_context): |
406 | 410 | """Test extract_dependent_function edge cases.""" |
407 | 411 | # No dependent functions |
408 | | - mock_code_context.testgen_context_code = """ |
| 412 | + mock_code_context.testgen_context = CodeStringsMarkdown.parse_markdown_code("""```python:file.py |
409 | 413 | def main_function(): |
410 | 414 | pass |
411 | | -""" |
| 415 | +``` |
| 416 | +""") |
412 | 417 | assert extract_dependent_function("main_function", mock_code_context) is False |
413 | 418 |
|
414 | 419 | # Multiple dependent functions |
415 | | - mock_code_context.testgen_context_code = """ |
| 420 | + mock_code_context.testgen_context = CodeStringsMarkdown.parse_markdown_code("""```python:file.py |
416 | 421 | def main_function(): |
417 | 422 | pass |
418 | | -
|
419 | 423 | def helper1(): |
420 | 424 | pass |
421 | 425 |
|
422 | 426 | async def helper2(): |
423 | 427 | pass |
424 | | -""" |
| 428 | +``` |
| 429 | +""") |
425 | 430 | assert extract_dependent_function("main_function", mock_code_context) is False |
426 | 431 |
|
427 | 432 |
|
428 | 433 | def test_extract_dependent_function_mixed_scenarios(mock_code_context): |
429 | 434 | """Test extract_dependent_function with mixed sync/async scenarios.""" |
430 | 435 | # Async main with sync helper |
431 | | - mock_code_context.testgen_context_code = """ |
| 436 | + mock_code_context.testgen_context = CodeStringsMarkdown.parse_markdown_code("""```python:file.py |
432 | 437 | async def async_main(): |
433 | 438 | pass |
434 | 439 |
|
435 | 440 | def sync_helper(): |
436 | 441 | pass |
437 | | -""" |
| 442 | +``` |
| 443 | +""") |
438 | 444 | assert extract_dependent_function("async_main", mock_code_context) == "sync_helper" |
439 | 445 |
|
440 | 446 | # Only async functions |
441 | | - mock_code_context.testgen_context_code = """ |
| 447 | + mock_code_context.testgen_context = CodeStringsMarkdown.parse_markdown_code("""```python:file.py |
442 | 448 | async def async_main(): |
443 | 449 | pass |
444 | 450 |
|
445 | 451 | async def async_helper(): |
446 | 452 | pass |
447 | | -""" |
| 453 | +``` |
| 454 | +""") |
| 455 | + |
448 | 456 | assert extract_dependent_function("async_main", mock_code_context) == "async_helper" |
449 | 457 |
|
450 | 458 |
|
|
0 commit comments