Skip to content

Commit 0dbb3a4

Browse files
committed
not used
1 parent a02e8a3 commit 0dbb3a4

1 file changed

Lines changed: 0 additions & 137 deletions

File tree

tests/test_code_replacement.py

Lines changed: 0 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from codeflash.languages.python.static_analysis.code_replacer import (
1212
AddRequestArgument,
1313
AutouseFixtureModifier,
14-
OptimFunctionCollector,
1514
PytestMarkAdder,
1615
is_zero_diff,
1716
replace_functions_and_add_imports,
@@ -3476,142 +3475,6 @@ def hydrate_input_text_actions_with_field_names(
34763475
assert new_code == expected
34773476

34783477

3479-
# OptimFunctionCollector async function tests
3480-
def test_optim_function_collector_with_async_functions():
3481-
"""Test OptimFunctionCollector correctly collects async functions."""
3482-
import libcst as cst
3483-
3484-
source_code = """
3485-
def sync_function():
3486-
return "sync"
3487-
3488-
async def async_function():
3489-
return "async"
3490-
3491-
class TestClass:
3492-
def sync_method(self):
3493-
return "sync_method"
3494-
3495-
async def async_method(self):
3496-
return "async_method"
3497-
"""
3498-
3499-
tree = cst.parse_module(source_code)
3500-
collector = OptimFunctionCollector(
3501-
function_names={
3502-
(None, "sync_function"),
3503-
(None, "async_function"),
3504-
("TestClass", "sync_method"),
3505-
("TestClass", "async_method"),
3506-
},
3507-
preexisting_objects=None,
3508-
)
3509-
tree.visit(collector)
3510-
3511-
# Should collect both sync and async functions
3512-
assert len(collector.modified_functions) == 4
3513-
assert (None, "sync_function") in collector.modified_functions
3514-
assert (None, "async_function") in collector.modified_functions
3515-
assert ("TestClass", "sync_method") in collector.modified_functions
3516-
assert ("TestClass", "async_method") in collector.modified_functions
3517-
3518-
3519-
def test_optim_function_collector_new_async_functions():
3520-
"""Test OptimFunctionCollector identifies new async functions not in preexisting objects."""
3521-
import libcst as cst
3522-
3523-
source_code = """
3524-
def existing_function():
3525-
return "existing"
3526-
3527-
async def new_async_function():
3528-
return "new_async"
3529-
3530-
def new_sync_function():
3531-
return "new_sync"
3532-
3533-
class ExistingClass:
3534-
async def new_class_async_method(self):
3535-
return "new_class_async"
3536-
"""
3537-
3538-
# Only existing_function is in preexisting objects
3539-
preexisting_objects = {("existing_function", ())}
3540-
3541-
tree = cst.parse_module(source_code)
3542-
collector = OptimFunctionCollector(
3543-
function_names=set(), # Not looking for specific functions
3544-
preexisting_objects=preexisting_objects,
3545-
)
3546-
tree.visit(collector)
3547-
3548-
# Should identify new functions (both sync and async)
3549-
assert len(collector.new_functions) == 2
3550-
function_names = [func.name.value for func in collector.new_functions]
3551-
assert "new_async_function" in function_names
3552-
assert "new_sync_function" in function_names
3553-
3554-
# Should identify new class methods
3555-
assert "ExistingClass" in collector.new_class_functions
3556-
assert len(collector.new_class_functions["ExistingClass"]) == 1
3557-
assert collector.new_class_functions["ExistingClass"][0].name.value == "new_class_async_method"
3558-
3559-
3560-
def test_optim_function_collector_mixed_scenarios():
3561-
"""Test OptimFunctionCollector with complex mix of sync/async functions and classes."""
3562-
import libcst as cst
3563-
3564-
source_code = """
3565-
# Global functions
3566-
def global_sync():
3567-
pass
3568-
3569-
async def global_async():
3570-
pass
3571-
3572-
class ParentClass:
3573-
def __init__(self):
3574-
pass
3575-
3576-
def sync_method(self):
3577-
pass
3578-
3579-
async def async_method(self):
3580-
pass
3581-
3582-
class ChildClass:
3583-
async def child_async_method(self):
3584-
pass
3585-
3586-
def child_sync_method(self):
3587-
pass
3588-
"""
3589-
3590-
# Looking for specific functions
3591-
function_names = {
3592-
(None, "global_sync"),
3593-
(None, "global_async"),
3594-
("ParentClass", "sync_method"),
3595-
("ParentClass", "async_method"),
3596-
("ChildClass", "child_async_method"),
3597-
}
3598-
3599-
tree = cst.parse_module(source_code)
3600-
collector = OptimFunctionCollector(function_names=function_names, preexisting_objects=None)
3601-
tree.visit(collector)
3602-
3603-
# Should collect all specified functions (mix of sync and async)
3604-
assert len(collector.modified_functions) == 5
3605-
assert (None, "global_sync") in collector.modified_functions
3606-
assert (None, "global_async") in collector.modified_functions
3607-
assert ("ParentClass", "sync_method") in collector.modified_functions
3608-
assert ("ParentClass", "async_method") in collector.modified_functions
3609-
assert ("ChildClass", "child_async_method") in collector.modified_functions
3610-
3611-
# Should collect __init__ method
3612-
assert "ParentClass" in collector.modified_init_functions
3613-
3614-
36153478
def test_is_zero_diff_async_sleep():
36163479
original_code = """
36173480
import time

0 commit comments

Comments
 (0)