refactor: CodeParser.parse_code

This commit is contained in:
莘权 马 2024-04-30 11:18:10 +08:00
parent a1eaf0b25d
commit 9c93da2b92
18 changed files with 25 additions and 29 deletions

View file

@ -110,7 +110,7 @@ async def test_write_refined_code(context, git_dir):
# old_workspace contains the legacy code
await context.repo.with_src_path(context.repo.old_workspace).srcs.save(
filename="game.py", content=CodeParser.parse_code(block="", text=REFINED_CODE_INPUT_SAMPLE)
filename="game.py", content=CodeParser.parse_code(text=REFINED_CODE_INPUT_SAMPLE)
)
ccontext = CodingContext(

View file

@ -45,7 +45,7 @@ async def test_write_code_plan_and_change_an(mocker, context, git_dir):
await context.repo.docs.task.save(filename="2.json", content=json.dumps(REFINED_TASK_JSON))
await context.repo.with_src_path(context.repo.old_workspace).srcs.save(
filename="game.py", content=CodeParser.parse_code(block="", text=REFINED_CODE_INPUT_SAMPLE)
filename="game.py", content=CodeParser.parse_code(text=REFINED_CODE_INPUT_SAMPLE)
)
root = ActionNode.from_children(

View file

@ -91,7 +91,7 @@ target_code = """task_list = [
def test_parse_code():
code = CodeParser.parse_code("Task list", TASKS, lang="python")
code = CodeParser.parse_code(block="Task list", text=TASKS, lang="python")
logger.info(code)
assert isinstance(code, str)
assert target_code == code

View file

@ -119,7 +119,7 @@ class TestCodeParser:
assert "game.py" in result
def test_parse_code(self, parser, text):
result = parser.parse_code("Task list", text, "python")
result = parser.parse_code(block="Task list", text=text, lang="python")
print(result)
assert "game.py" in result