From c3f85c3bb21e4d17b5b7d2601287bdbf55e81ea3 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 11 Dec 2024 20:43:07 -0800 Subject: [PATCH] test: Fix gitignore pattern matching and add ai comment test --- tests/basic/test_watch.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/basic/test_watch.py b/tests/basic/test_watch.py index 3cfa39264..25612183f 100644 --- a/tests/basic/test_watch.py +++ b/tests/basic/test_watch.py @@ -7,15 +7,16 @@ from aider.watch import FileWatcher def test_gitignore_patterns(): """Test that gitignore patterns are properly loaded and matched""" from pathlib import Path + from aider.watch import load_gitignores # Create a temporary gitignore file with test patterns tmp_gitignore = Path("test.gitignore") tmp_gitignore.write_text("custom_pattern\n*.custom") - + gitignores = [tmp_gitignore] spec = load_gitignores(gitignores) - + # Test built-in patterns assert spec.match_file(".aider.conf") assert spec.match_file(".git/config") @@ -46,19 +47,20 @@ def test_gitignore_patterns(): assert spec.match_file(".cache/files") assert spec.match_file(".pytest_cache/v/cache") assert spec.match_file("coverage/lcov.info") - + # Test custom patterns from gitignore file assert spec.match_file("custom_pattern") assert spec.match_file("file.custom") - + # Test non-matching patterns assert not spec.match_file("regular_file.txt") assert not spec.match_file("src/main.py") assert not spec.match_file("docs/index.html") - + # Cleanup tmp_gitignore.unlink() + def test_ai_comment_pattern(): # Create minimal IO and Coder instances for testing class MinimalCoder: