fix: handle macOS /private/ prefix in file path tests

This commit is contained in:
Paul Gauthier (aider) 2024-10-29 13:21:31 -07:00
parent 26a85c2047
commit 56f3220d4c

View file

@ -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