1
1
import os
2
2
3
- from clang .cindex import Config , File , Index
3
+ from clang .cindex import Config , File , Index , TranslationUnit
4
4
5
5
if "CLANG_LIBRARY_PATH" in os .environ :
6
6
Config .set_library_path (os .environ ["CLANG_LIBRARY_PATH" ])
7
7
8
8
import unittest
9
9
10
+ kInputsDir = os .path .join (os .path .dirname (__file__ ), "INPUTS" )
10
11
11
12
class TestFile (unittest .TestCase ):
12
13
def test_file (self ):
@@ -18,16 +19,14 @@ def test_file(self):
18
19
self .assertEqual (repr (file ), "<File: t.c>" )
19
20
20
21
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
+
31
29
self .assertEqual (file1 , file1 )
30
+ self .assertEqual (file2 , file2_2 )
32
31
self .assertNotEqual (file1 , file2 )
33
32
self .assertNotEqual (file1 , "t.c" )
0 commit comments