From 311981f4e5b39bfa5431fe11fda58cf13f200b12 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 8 May 2025 14:39:14 -0700 Subject: [PATCH] test: Use os.path.samefile for robust read-only file assertion --- tests/basic/test_commands.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/basic/test_commands.py b/tests/basic/test_commands.py index 2d15e02f5..8f668c6f5 100644 --- a/tests/basic/test_commands.py +++ b/tests/basic/test_commands.py @@ -2147,7 +2147,11 @@ class TestCommands(TestCase): # Assertions for /reset self.assertEqual(len(new_coder.abs_fnames), 0) self.assertEqual(len(new_coder.abs_read_only_fnames), 1) - self.assertIn(str(orig_ro_path), new_coder.abs_read_only_fnames) + # self.assertIn(str(orig_ro_path), new_coder.abs_read_only_fnames) + self.assertTrue( + any(os.path.samefile(p, str(orig_ro_path)) for p in new_coder.abs_read_only_fnames), + f"File {str(orig_ro_path)} not found in {new_coder.abs_read_only_fnames}", + ) self.assertEqual(len(new_coder.done_messages), 0) self.assertEqual(len(new_coder.cur_messages), 0) @@ -2186,6 +2190,10 @@ class TestCommands(TestCase): self.assertEqual(len(new_coder.abs_fnames), 0) self.assertEqual(len(new_coder.abs_read_only_fnames), 1) - self.assertIn(str(orig_ro_path), new_coder.abs_read_only_fnames) + # self.assertIn(str(orig_ro_path), new_coder.abs_read_only_fnames) + self.assertTrue( + any(os.path.samefile(p, str(orig_ro_path)) for p in new_coder.abs_read_only_fnames), + f"File {str(orig_ro_path)} not found in {new_coder.abs_read_only_fnames}", + ) self.assertEqual(new_coder.done_messages, [{"role": "user", "content": "d1"}]) self.assertEqual(new_coder.cur_messages, [{"role": "user", "content": "c1"}])