mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-23 15:48:11 +02:00
refactor: CodeParser.parse_code
This commit is contained in:
parent
a1eaf0b25d
commit
9c93da2b92
18 changed files with 25 additions and 29 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue