From 56f3220d4c5eba2c87b9072134be7ccf7111318e Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 29 Oct 2024 13:21:31 -0700 Subject: [PATCH] fix: handle macOS /private/ prefix in file path tests --- tests/basic/test_commands.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/basic/test_commands.py b/tests/basic/test_commands.py index be592b09e..2d8291ca8 100644 --- a/tests/basic/test_commands.py +++ b/tests/basic/test_commands.py @@ -749,7 +749,14 @@ class TestCommands(TestCase): with open(session_file, encoding=io.encoding) as f: commands_text = f.read() self.assertIn("/add file1.txt", commands_text) - self.assertIn(f"/read-only {external_file_path}", commands_text) + # Split commands and check each one + for line in commands_text.splitlines(): + if line.startswith("/read-only "): + saved_path = line.split(" ", 1)[1] + if os.path.samefile(saved_path, external_file_path): + break + else: + self.fail(f"No matching read-only command found for {external_file_path}") # Clear the current session commands.cmd_reset("") @@ -815,7 +822,14 @@ class TestCommands(TestCase): with open(session_file, encoding=io.encoding) as f: commands_text = f.read() self.assertIn("/add internal1.txt", commands_text) - self.assertIn(f"/read-only {external_file1_path}", commands_text) + # Split commands and check each one + for line in commands_text.splitlines(): + if line.startswith("/read-only "): + saved_path = line.split(" ", 1)[1] + if os.path.samefile(saved_path, external_file1_path): + break + else: + self.fail(f"No matching read-only command found for {external_file1_path}") self.assertIn(f"/read-only {external_file2_path}", commands_text) # Clear the current session