mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-27 14:25:20 +02:00
editor use tmpfile to backup
This commit is contained in:
parent
09f25460be
commit
190405ac3c
5 changed files with 40 additions and 21 deletions
|
|
@ -545,7 +545,7 @@ def test_edit_file_by_replace_to_palce_empty(empty_file):
|
|||
editor.edit_file_by_replace(
|
||||
file_name=str(empty_file), to_replace="", new_content=EXPECTED_CONTENT_AFTER_REPLACE_TEXT.strip()
|
||||
)
|
||||
assert "is empty. Use the append method to add content." in str(exc_info.value)
|
||||
assert "is empty. Use the append method to add content." in str(exc_info.value)
|
||||
|
||||
|
||||
def test_append_file(temp_file_path):
|
||||
|
|
@ -604,6 +604,27 @@ def test_search_dir(tmp_path):
|
|||
assert "Another file with different content." not in result
|
||||
|
||||
|
||||
def test_search_dir_in_default_dir(tmp_path):
|
||||
editor = Editor()
|
||||
dir_path = editor.working_dir / "test_dir"
|
||||
dir_path.mkdir(exist_ok=True)
|
||||
|
||||
# Create some files with specific content
|
||||
(dir_path / "file1.txt").write_text("This is a test file with some content.")
|
||||
(dir_path / "file2.txt").write_text("Another file with different content.")
|
||||
sub_dir = dir_path / "sub_dir"
|
||||
sub_dir.mkdir(exist_ok=True)
|
||||
(sub_dir / "file3.txt").write_text("This file is inside a sub directory with some content.")
|
||||
|
||||
search_term = "some content"
|
||||
|
||||
result = editor.search_dir(search_term)
|
||||
|
||||
assert "file1.txt" in result
|
||||
assert "file3.txt" in result
|
||||
assert "Another file with different content." not in result
|
||||
|
||||
|
||||
def test_search_file(temp_file_path):
|
||||
editor = Editor()
|
||||
file_path = temp_file_path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue