mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 13:54:59 +00:00
aider: Switched all the os calls to use pathlib in test_cmd_add_drop_directory
.
# Aider chat conversation: USER: switch all the os calls to use pathlib in `test_cmd_add_drop_directory` ASSISTANT: To switch all the os calls to use pathlib in `test_cmd_add_drop_directory`, we need to modify the `tests/test_commands.py` file. Here are the changes: ```python tests/test_commands.py <<<<<<< ORIGINAL # Create a directory and add files to it os.mkdir("test_dir") os.mkdir("test_dir/another_dir") with open("test_dir/test_file1.txt", "w") as f: f.write("Test file 1") with open("test_dir/test_file2.txt", "w") as f: f.write("Test file 2") with open("test_dir/another_dir/test_file.txt", "w") as f: f.write("Test file 3") ======= # Create a directory and add files to it using pathlib Path("test_dir").mkdir() Path("test_dir/another_dir").mkdir() with open(Path("test_dir/test_file1.txt"), "w") as f: f.write("Test file 1") with open(Path("test_dir/test_file2.txt"), "w") as f: f.write("Test file 2") with open(Path("test_dir/another_dir/test_file.txt"), "w") as f: f.write("Test file 3") >>>>>>> UPDATED ``` This change replaces the `os.mkdir` calls with `Path().mkdir()` from the pathlib module. It also changes the file paths in the `open` calls to use `Path()`.
This commit is contained in:
parent
0e9dbddfde
commit
d695fe103b
1 changed files with 6 additions and 6 deletions
|
@ -90,14 +90,14 @@ class TestCommands(TestCase):
|
|||
coder = Coder.create(models.GPT35, None, io)
|
||||
commands = Commands(io, coder)
|
||||
|
||||
# Create a directory and add files to it
|
||||
os.mkdir("test_dir")
|
||||
os.mkdir("test_dir/another_dir")
|
||||
with open("test_dir/test_file1.txt", "w") as f:
|
||||
# Create a directory and add files to it using pathlib
|
||||
Path("test_dir").mkdir()
|
||||
Path("test_dir/another_dir").mkdir()
|
||||
with open(Path("test_dir/test_file1.txt"), "w") as f:
|
||||
f.write("Test file 1")
|
||||
with open("test_dir/test_file2.txt", "w") as f:
|
||||
with open(Path("test_dir/test_file2.txt"), "w") as f:
|
||||
f.write("Test file 2")
|
||||
with open("test_dir/another_dir/test_file.txt", "w") as f:
|
||||
with open(Path("test_dir/another_dir/test_file.txt"), "w") as f:
|
||||
f.write("Test file 3")
|
||||
|
||||
# Call the cmd_add method with a directory
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue