mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-22 13:25:00 +00:00
Add a test that checks if the cmd_lint command correctly identifies a dirty file in a repository.
This commit is contained in:
parent
1a3466e413
commit
894eff4393
1 changed files with 36 additions and 0 deletions
|
@ -701,3 +701,39 @@ class TestCommands(TestCase):
|
|||
self.assertNotIn(fname1, str(coder.abs_fnames))
|
||||
self.assertNotIn(fname2, str(coder.abs_fnames))
|
||||
self.assertNotIn(fname3, str(coder.abs_fnames))
|
||||
|
||||
def test_cmd_lint_with_dirty_file(self):
|
||||
with GitTemporaryDirectory() as repo_dir:
|
||||
repo = git.Repo(repo_dir)
|
||||
io = InputOutput(pretty=False, yes=True)
|
||||
coder = Coder.create(self.GPT35, None, io)
|
||||
commands = Commands(io, coder)
|
||||
|
||||
# Create and commit a file
|
||||
filename = "test_file.py"
|
||||
file_path = Path(repo_dir) / filename
|
||||
file_path.write_text("def hello():\n print('Hello, World!')\n")
|
||||
repo.git.add(filename)
|
||||
repo.git.commit("-m", "Add test_file.py")
|
||||
|
||||
# Modify the file to make it dirty
|
||||
file_path.write_text("def hello():\n print('Hello, World!')\n\n# Dirty line\n")
|
||||
|
||||
# Capture the output
|
||||
captured_output = StringIO()
|
||||
sys.stdout = captured_output
|
||||
|
||||
# Run cmd_lint
|
||||
commands.cmd_lint()
|
||||
|
||||
# Restore stdout
|
||||
sys.stdout = sys.__stdout__
|
||||
|
||||
# Check if the dirty file was detected
|
||||
output = captured_output.getvalue()
|
||||
self.assertIn("test_file.py", output)
|
||||
self.assertIn("Dirty files to lint", output)
|
||||
|
||||
del coder
|
||||
del commands
|
||||
del repo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue