| 1 |
import os |
| 2 |
from clang.cindex import Config |
| 3 |
|
| 4 |
if "CLANG_LIBRARY_PATH" in os.environ: |
| 5 |
Config.set_library_path(os.environ["CLANG_LIBRARY_PATH"]) |
| 6 |
|
| 7 |
from clang.cindex import Index, File |
| 8 |
|
| 9 |
import unittest |
| 10 |
|
| 11 |
|
| 12 |
class TestFile(unittest.TestCase): |
| 13 |
def test_file(self): |
| 14 |
index = Index.create() |
| 15 |
tu = index.parse("t.c", unsaved_files=[("t.c", "")]) |
| 16 |
file = File.from_name(tu, "t.c") |
| 17 |
self.assertEqual(str(file), "t.c") |
| 18 |
self.assertEqual(file.name, "t.c") |
| 19 |
self.assertEqual(repr(file), "<File: t.c>") |