Skip to content

Commit c40bd5e

Browse files
committed
Use existing test input files instead of in-memory files
1 parent 8a20661 commit c40bd5e

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import os
22

3-
from clang.cindex import Config, File, Index
3+
from clang.cindex import Config, File, Index, TranslationUnit
44

55
if "CLANG_LIBRARY_PATH" in os.environ:
66
Config.set_library_path(os.environ["CLANG_LIBRARY_PATH"])
77

88
import unittest
99

10+
kInputsDir = os.path.join(os.path.dirname(__file__), "INPUTS")
1011

1112
class 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

Comments
 (0)