mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-25 16:56:26 +02:00
remove the outdated editor results.
This commit is contained in:
parent
b112074030
commit
a8aaece8fb
4 changed files with 68 additions and 46 deletions
|
|
@ -538,11 +538,11 @@ def test_edit_file_by_replace(temp_py_file):
|
|||
editor = Editor()
|
||||
editor.edit_file_by_replace(
|
||||
file_name=str(temp_py_file),
|
||||
start_line_number=5,
|
||||
start_line_content=" b = 2",
|
||||
first_replaced_line_number=5,
|
||||
first_replaced_line_content=" b = 2",
|
||||
new_content=" b = 9",
|
||||
end_line_number=5,
|
||||
end_line_content=" b = 2",
|
||||
last_replaced_line_number=5,
|
||||
last_replaced_line_content=" b = 2",
|
||||
)
|
||||
with open(temp_py_file, "r") as f:
|
||||
new_content = f.read()
|
||||
|
|
@ -550,9 +550,9 @@ def test_edit_file_by_replace(temp_py_file):
|
|||
|
||||
|
||||
MISMATCH_ERROR = """
|
||||
Error: The `start_line_number` does not match the `start_line_content`. Please correct the parameters.
|
||||
The `start_line_number` is 5 and the corresponding content is " b = 2".
|
||||
But the `start_line_content` is "".
|
||||
Error: The `first_replaced_replaced_line_number` does not match the `first_replaced_replaced_line_content`. Please correct the parameters.
|
||||
The `first_replaced_replaced_line_number` is 5 and the corresponding content is " b = 2".
|
||||
But the `first_replaced_replaced_line_content ` is "".
|
||||
The content around the specified line is:
|
||||
002|def test_function_for_fm():
|
||||
003| "some docstring"
|
||||
|
|
@ -560,9 +560,10 @@ The content around the specified line is:
|
|||
005| b = 2
|
||||
006| c = 3
|
||||
007| # this is the 7th line
|
||||
Error: The `end_line_number` does not match the `end_line_content`. Please correct the parameters.
|
||||
The `end_line_number` is 5 and the corresponding content is " b = 2".
|
||||
But the `end_line_content` is "".
|
||||
Pay attention to the new content. Ensure that it aligns with the new parameters.
|
||||
Error: The `last_replaced_replaced_line_number` does not match the `last_replaced_replaced_line_content`. Please correct the parameters.
|
||||
The `last_replaced_replaced_line_number` is 5 and the corresponding content is " b = 2".
|
||||
But the `last_replaced_replaced_line_content ` is "".
|
||||
The content around the specified line is:
|
||||
002|def test_function_for_fm():
|
||||
003| "some docstring"
|
||||
|
|
@ -570,6 +571,7 @@ The content around the specified line is:
|
|||
005| b = 2
|
||||
006| c = 3
|
||||
007| # this is the 7th line
|
||||
Pay attention to the new content. Ensure that it aligns with the new parameters.
|
||||
""".strip()
|
||||
|
||||
|
||||
|
|
@ -577,14 +579,12 @@ def test_edit_file_by_replace_mismatch(temp_py_file):
|
|||
editor = Editor()
|
||||
output = editor.edit_file_by_replace(
|
||||
file_name=str(temp_py_file),
|
||||
start_line_number=5,
|
||||
start_line_content="",
|
||||
first_replaced_line_number=5,
|
||||
first_replaced_line_content="",
|
||||
new_content=" b = 9",
|
||||
end_line_number=5,
|
||||
end_line_content="",
|
||||
last_replaced_line_number=5,
|
||||
last_replaced_line_content="",
|
||||
)
|
||||
with open("tmp.txt", "w", encoding="utf-8") as f:
|
||||
f.write(output)
|
||||
assert output.strip() == MISMATCH_ERROR.strip()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue