11import os
22
3- from clang .cindex import Config , File , Index
3+ from clang .cindex import Config , File , Index , TranslationUnit
44
55if "CLANG_LIBRARY_PATH" in os .environ :
66 Config .set_library_path (os .environ ["CLANG_LIBRARY_PATH" ])
77
88import unittest
99
10+ kInputsDir = os .path .join (os .path .dirname (__file__ ), "INPUTS" )
1011
1112class TestFile (unittest .TestCase ):
1213 def test_file (self ):
@@ -18,16 +19,14 @@ def test_file(self):
1819 self .assertEqual (repr (file ), "<File: t.c>" )
1920
2021 def test_file_eq (self ):
21- index = Index .create ()
22- tu = index .parse (
23- "t.c" ,
24- unsaved_files = [
25- ("t.c" , "int a = 729;" ),
26- ("s.c" , "int a = 729;" ),
27- ],
28- )
29- file1 = File .from_name (tu , "t.c" )
30- file2 = File .from_name (tu , "s.c" )
22+ path = os .path .join (kInputsDir , "hello.cpp" )
23+ header_path = os .path .join (kInputsDir , "header3.h" )
24+ tu = TranslationUnit .from_source (path )
25+ file1 = File .from_name (tu , path )
26+ file2 = File .from_name (tu , header_path )
27+ file2_2 = File .from_name (tu , header_path )
28+
3129 self .assertEqual (file1 , file1 )
30+ self .assertEqual (file2 , file2_2 )
3231 self .assertNotEqual (file1 , file2 )
3332 self .assertNotEqual (file1 , "t.c" )
0 commit comments