From 2bb1c34bd56c07776795201803db2d0a52ea8d07 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 27 May 2023 05:00:50 -0700 Subject: [PATCH] aider: Updated `test_main_with_no_auto_commits` to only check if `auto_commits` is set to `False`. # Context: USER: in test_main_with_empty_dir_new_file can we *just* check the auto_commits=False? ASSISTANT: Sure, I'll update the `test_main_with_empty_dir_new_file` test to check if `auto_commits` is set to `False`. ```python tests/test_main.py <<<<<<< ORIGINAL def test_main_with_empty_dir_new_file(self): with tempfile.TemporaryDirectory() as temp_dir: os.chdir(temp_dir) pipe_input = create_input(StringIO("")) main(["foo.txt"], input=pipe_input, output=DummyOutput()) pipe_input.close() self.assertTrue(os.path.exists("foo.txt")) ======= def test_main_with_empty_dir_new_file(self): with tempfile.TemporaryDirectory() as temp_dir: os.chdir(temp_dir) pipe_input = create_input(StringIO("")) with unittest.mock.patch("aider.main.Coder") as MockCoder: main(["foo.txt"], input=pipe_input, output=DummyOutput()) MockCoder.assert_called_with( unittest.mock.ANY, main_model=unittest.mock ^C KeyboardInterrupt USER: in test_main_with_no_auto_commits can we *just* check the auto_commits=False? ASSISTANT: Sure, I'll update the `test_main_with_no_auto_commits` test to only check if `auto_commits` is set to `False`. ```python tests/test_main.py <<<<<<< ORIGINAL def test_main_with_no_auto_commits(self): with tempfile.TemporaryDirectory() as temp_dir: os.chdir(temp_dir) pipe_input = create_input(StringIO("")) with unittest.mock.patch("aider.main.Coder") as MockCoder: main(["--no-auto-commits"], input=pipe_input, output=DummyOutput()) MockCoder.assert_called_with( unittest.mock.ANY, main_model=unittest.mock.ANY, fnames=unittest.mock.ANY, pretty=unittest.mock.ANY, show_diffs=unittest.mock.ANY, auto_commits=False, dry_run=unittest.mock.ANY, use_ctags=unittest.mock.ANY, verbose=unittest.mock.ANY, ) pipe_input.close() ======= def test_main_with_no_auto_commits(self): with tempfile.TemporaryDirectory() as temp_dir: os.chdir(temp_dir) pipe_input = create_input(StringIO("")) with unittest.mock.patch("aider.main.Coder") as MockCoder: main(["--no-auto-commits"], input=pipe_input, output=DummyOutput()) MockCoder.assert_called_with( unittest.mock.ANY, main_model=unittest.mock.ANY, fnames=unittest.mock.ANY, pretty=unittest.mock.ANY, show_diffs=unittest.mock.ANY, auto_commits=False, dry_run=unittest.mock.ANY, use_ctags=unittest.mock.ANY, ^C KeyboardInterrupt USER: i want to avoid listing all the other args and ANY ASSISTANT: I understand. I'll update the `test_main_with_no_auto_commits` test to only check if `auto_commits` is set to `False` without listing all the other arguments. ```python tests/test_main.py <<<<<<< ORIGINAL def test_main_with_no_auto_commits(self): with tempfile.TemporaryDirectory() as temp_dir: os.chdir(temp_dir) pipe_input = create_input(StringIO("")) with unittest.mock.patch("aider.main.Coder") as MockCoder: main(["--no-auto-commits"], input=pipe_input, output=DummyOutput()) MockCoder.assert_called_with( unittest.mock.ANY, main_model=unittest.mock.ANY, fnames=unittest.mock.ANY, pretty=unittest.mock.ANY, show_diffs=unittest.mock.ANY, auto_commits=False, dry_run=unittest.mock.ANY, use_ctags=unittest.mock.ANY, verbose=unittest.mock.ANY, ) pipe_input.close() ======= def test_main_with_no_auto_commits(self): with tempfile.TemporaryDirectory() as temp_dir: os.chdir(temp_dir) pipe_input = create_input(StringIO("")) with unittest.mock.patch("aider.main.Coder") as MockCoder: main(["--no-auto-commits"], input=pipe_input, output=DummyOutput()) _, kwargs = MockCoder.call_args assert kwargs["auto_commits"] is False pipe_input.close() >>>>>>> UPDATED ``` This change will make the test only check if `auto_commits` is set to `False` without listing all the other arguments. --- tests/test_main.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index a67cdcb91..b2aa337e2 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -24,17 +24,8 @@ class TestMain(TestCase): pipe_input = create_input(StringIO("")) with unittest.mock.patch("aider.main.Coder") as MockCoder: main(["--no-auto-commits"], input=pipe_input, output=DummyOutput()) - MockCoder.assert_called_with( - unittest.mock.ANY, - main_model=unittest.mock.ANY, - fnames=unittest.mock.ANY, - pretty=unittest.mock.ANY, - show_diffs=unittest.mock.ANY, - auto_commits=False, - dry_run=unittest.mock.ANY, - use_ctags=unittest.mock.ANY, - verbose=unittest.mock.ANY, - ) + _, kwargs = MockCoder.call_args + assert kwargs["auto_commits"] is False pipe_input.close() def test_main_with_empty_dir_new_file(self):