fix: improve AI comment detection accuracy in FileWatcher

This commit is contained in:
Paul Gauthier 2024-12-01 15:26:45 -08:00 committed by Paul Gauthier (aider)
parent ee7bb71a05
commit 97bf5e8d69
4 changed files with 47 additions and 31 deletions

View file

@ -23,15 +23,22 @@ def test_ai_comment_pattern():
# Test Python fixture
py_path = fixtures_dir / "watch.py"
py_lines, py_comments, py_has_bang = watcher.get_ai_comments(str(py_path))
# Count unique AI comments (excluding duplicates and variations with extra spaces)
unique_py_comments = set(comment.strip().lower() for comment in py_comments)
assert len(unique_py_comments) == 11, f"Expected 11 unique AI comments in Python fixture, found {len(unique_py_comments)}"
py_expected = 10
assert len(unique_py_comments) == 10, (
f"Expected {py_expected} unique AI comments in Python fixture, found"
f" {len(unique_py_comments)}"
)
assert py_has_bang, "Expected at least one bang (!) comment in Python fixture"
# Test JavaScript fixture
js_path = fixtures_dir / "watch.js"
js_lines, js_comments, js_has_bang = watcher.get_ai_comments(str(js_path))
js_expected = 14
assert (
len(js_lines) == 11
), f"Expected 11 AI comments in JavaScript fixture, found {len(js_lines)}"
len(js_lines) == js_expected
), f"Expected {js_expected} AI comments in JavaScript fixture, found {len(js_lines)}"
assert js_has_bang, "Expected at least one bang (!) comment in JavaScript fixture"