fix: use platform-agnostic paths in test_commands.py

This commit is contained in:
Paul Gauthier (aider) 2024-10-29 13:11:00 -07:00
parent f9005451fa
commit 4a3cb8dc95

View file

@ -694,7 +694,6 @@ class TestCommands(TestCase):
# Clean up # Clean up
Path(session_file).unlink() Path(session_file).unlink()
#ai this test fails on windows because it uses /, fix it!
def test_cmd_save_and_load_with_external_file(self): def test_cmd_save_and_load_with_external_file(self):
with tempfile.NamedTemporaryFile(mode="w", delete=False) as external_file: with tempfile.NamedTemporaryFile(mode="w", delete=False) as external_file:
external_file.write("External file content") external_file.write("External file content")
@ -718,11 +717,11 @@ class TestCommands(TestCase):
full_path.write_text(content) full_path.write_text(content)
# Add some files as editable and some as read-only # Add some files as editable and some as read-only
commands.cmd_add("file1.txt") commands.cmd_add(str(Path("file1.txt")))
commands.cmd_read_only(external_file_path) commands.cmd_read_only(external_file_path)
# Save the session to a file # Save the session to a file
session_file = "test_session.txt" session_file = str(Path("test_session.txt"))
commands.cmd_save(session_file) commands.cmd_save(session_file)
# Verify the session file was created and contains the expected commands # Verify the session file was created and contains the expected commands
@ -744,7 +743,7 @@ class TestCommands(TestCase):
added_files = {coder.get_rel_fname(f) for f in coder.abs_fnames} added_files = {coder.get_rel_fname(f) for f in coder.abs_fnames}
read_only_files = {coder.get_rel_fname(f) for f in coder.abs_read_only_fnames} read_only_files = {coder.get_rel_fname(f) for f in coder.abs_read_only_fnames}
self.assertEqual(added_files, {"file1.txt"}) self.assertEqual(added_files, {str(Path("file1.txt"))})
self.assertEqual(read_only_files, {external_file_path}) self.assertEqual(read_only_files, {external_file_path})
# Clean up # Clean up