File size: 562 Bytes
1afb40b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import pytest
from pathlib import Path
from src.tools.code_graph import CodeGraphIndexer

def test_code_graph_unparseable_file(tmp_path):
    # Create a broken/unparseable file that causes ast.parse to fail
    broken_file = tmp_path / "broken.py"
    broken_file.write_text("def invalid_syntax( :", encoding="utf-8")
    
    indexer = CodeGraphIndexer(repo_root=str(tmp_path))
    res = indexer.build_index()
    
    # Should catch the exception, skip the file, and complete successfully
    assert "indexed_files" in res
    assert res["indexed_files"] == 1