mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
feat: Add test for --lint option
This commit is contained in:
parent
103452aa21
commit
bb279d6899
1 changed files with 25 additions and 0 deletions
|
@ -327,6 +327,31 @@ class TestMain(TestCase):
|
||||||
_, kwargs = MockCoder.call_args
|
_, kwargs = MockCoder.call_args
|
||||||
self.assertEqual(kwargs["show_diffs"], True)
|
self.assertEqual(kwargs["show_diffs"], True)
|
||||||
|
|
||||||
|
def test_lint_option(self):
|
||||||
|
with GitTemporaryDirectory() as git_dir:
|
||||||
|
# Create a dirty file in the root
|
||||||
|
dirty_file = Path(git_dir) / "dirty_file.py"
|
||||||
|
dirty_file.write_text("def foo():\n return 'bar'")
|
||||||
|
|
||||||
|
# Create a subdirectory
|
||||||
|
subdir = Path(git_dir) / "subdir"
|
||||||
|
subdir.mkdir()
|
||||||
|
|
||||||
|
# Change to the subdirectory
|
||||||
|
os.chdir(subdir)
|
||||||
|
|
||||||
|
# Mock the Linter class
|
||||||
|
with patch("aider.linter.Linter") as MockLinter:
|
||||||
|
mock_linter_instance = MockLinter.return_value
|
||||||
|
mock_linter_instance.lint.return_value = "Linting results"
|
||||||
|
|
||||||
|
# Run main with --lint option
|
||||||
|
main(["--lint", "--no-git"], input=DummyInput(), output=DummyOutput())
|
||||||
|
|
||||||
|
# Check if the Linter was called with the correct file
|
||||||
|
MockLinter.assert_called_once()
|
||||||
|
mock_linter_instance.lint.assert_called_once_with(str(dirty_file))
|
||||||
|
|
||||||
def test_verbose_mode_lists_env_vars(self):
|
def test_verbose_mode_lists_env_vars(self):
|
||||||
self.create_env_file(".env", "AIDER_DARK_MODE=on")
|
self.create_env_file(".env", "AIDER_DARK_MODE=on")
|
||||||
with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
|
with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue