From da5ea3a767060f0328fdb9e98b3c45cc70de11cc Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 9 Aug 2024 16:43:08 -0400 Subject: [PATCH] feat: add test for reading external file with --read option --- tests/basic/test_main.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/basic/test_main.py b/tests/basic/test_main.py index d300c7ccf..db9ddca09 100644 --- a/tests/basic/test_main.py +++ b/tests/basic/test_main.py @@ -401,12 +401,30 @@ class TestMain(TestCase): with GitTemporaryDirectory(): test_file = "test_file.txt" Path(test_file).touch() - + coder = main( ["--read", test_file, "--exit", "--yes"], input=DummyInput(), output=DummyOutput(), return_coder=True, ) - + self.assertIn(str(Path(test_file).resolve()), coder.abs_read_only_fnames) + + def test_read_option_with_external_file(self): + with tempfile.NamedTemporaryFile(mode='w', delete=False) as external_file: + external_file.write("External file content") + external_file_path = external_file.name + + try: + with GitTemporaryDirectory(): + coder = main( + ["--read", external_file_path, "--exit", "--yes"], + input=DummyInput(), + output=DummyOutput(), + return_coder=True, + ) + + self.assertIn(external_file_path, coder.abs_read_only_fnames) + finally: + os.unlink(external_file_path)