mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 06:44:59 +00:00
refactor: update test to read AI comments from fixture files
This commit is contained in:
parent
e885f848a6
commit
7a3fd11b6b
1 changed files with 20 additions and 30 deletions
|
@ -1,36 +1,26 @@
|
|||
from pathlib import Path
|
||||
from aider.watch import FileWatcher
|
||||
|
||||
|
||||
def test_ai_comment_pattern():
|
||||
# Test various AI comment patterns
|
||||
test_comments = [
|
||||
# Python style
|
||||
"# ai do something",
|
||||
"# AI make this better",
|
||||
"# ai! urgent change needed",
|
||||
"# AI! another urgent one",
|
||||
# JavaScript style
|
||||
"//ai do something",
|
||||
"//AI make this better",
|
||||
"//ai! urgent change needed",
|
||||
"//AI! another urgent one",
|
||||
"// ai with space",
|
||||
"// AI with caps",
|
||||
"// ai! with bang",
|
||||
]
|
||||
# Read fixture files
|
||||
fixtures_dir = Path(__file__).parent.parent / "fixtures"
|
||||
|
||||
with open(fixtures_dir / "watch.py") as f:
|
||||
py_content = f.read()
|
||||
with open(fixtures_dir / "watch.js") as f:
|
||||
js_content = f.read()
|
||||
|
||||
# Non-AI comments that shouldn't match
|
||||
non_ai_comments = [
|
||||
"# this is not an ai comment",
|
||||
"// this is also not an ai comment",
|
||||
"# aider is not an ai comment",
|
||||
"// aider is not an ai comment",
|
||||
]
|
||||
# Count AI comments in Python fixture
|
||||
py_matches = 0
|
||||
for line in py_content.splitlines():
|
||||
if FileWatcher.ai_comment_pattern.search(line):
|
||||
py_matches += 1
|
||||
assert py_matches == 11, f"Expected 11 AI comments in Python fixture, found {py_matches}"
|
||||
|
||||
# Test that all AI comments match
|
||||
for comment in test_comments:
|
||||
assert FileWatcher.ai_comment_pattern.search(comment), f"Should match: {comment}"
|
||||
|
||||
# Test that non-AI comments don't match
|
||||
for comment in non_ai_comments:
|
||||
assert not FileWatcher.ai_comment_pattern.search(comment), f"Should not match: {comment}"
|
||||
# Count AI comments in JavaScript fixture
|
||||
js_matches = 0
|
||||
for line in js_content.splitlines():
|
||||
if FileWatcher.ai_comment_pattern.search(line):
|
||||
js_matches += 1
|
||||
assert js_matches == 11, f"Expected 11 AI comments in JavaScript fixture, found {js_matches}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue