mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
refactor: update test to use get_ai_comments method
This commit is contained in:
parent
e9ce04ffe9
commit
154cb463e5
1 changed files with 12 additions and 19 deletions
|
@ -1,27 +1,20 @@
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from aider.watch import FileWatcher
|
from aider.watch import FileWatcher
|
||||||
|
|
||||||
|
|
||||||
def test_ai_comment_pattern():
|
def test_ai_comment_pattern():
|
||||||
# Read fixture files
|
# Create a FileWatcher instance for testing
|
||||||
|
watcher = FileWatcher(None)
|
||||||
fixtures_dir = Path(__file__).parent.parent / "fixtures"
|
fixtures_dir = Path(__file__).parent.parent / "fixtures"
|
||||||
|
|
||||||
with open(fixtures_dir / "watch.py") as f:
|
# Test Python fixture
|
||||||
py_content = f.read()
|
py_path = fixtures_dir / "watch.py"
|
||||||
with open(fixtures_dir / "watch.js") as f:
|
py_lines, py_comments, py_has_bang = watcher.get_ai_comments(str(py_path))
|
||||||
js_content = f.read()
|
assert len(py_lines) == 11, f"Expected 11 AI comments in Python fixture, found {len(py_lines)}"
|
||||||
|
assert py_has_bang, "Expected at least one bang (!) comment in Python fixture"
|
||||||
|
|
||||||
# Count AI comments in Python fixture
|
# Test JavaScript fixture
|
||||||
py_matches = 0
|
js_path = fixtures_dir / "watch.js"
|
||||||
for line in py_content.splitlines():
|
js_lines, js_comments, js_has_bang = watcher.get_ai_comments(str(js_path))
|
||||||
if FileWatcher.ai_comment_pattern.search(line):
|
assert len(js_lines) == 11, f"Expected 11 AI comments in JavaScript fixture, found {len(js_lines)}"
|
||||||
py_matches += 1
|
assert js_has_bang, "Expected at least one bang (!) comment in JavaScript fixture"
|
||||||
assert py_matches == 11, f"Expected 11 AI comments in Python fixture, found {py_matches}"
|
|
||||||
|
|
||||||
# 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