From d695fe103b2f0352c8b72a2b75587ec8c59bf0a9 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 23 Jul 2023 08:18:34 -0300 Subject: [PATCH] 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()`. --- tests/test_commands.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index 02f808fae..06bd10ce1 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -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