Files
clang-p2996/clang/bindings/python/tests/cindex/test_index.py
Jannick Kremer 71cfa381ef [libclang/python/tests] Clean up imports (#114409)
Sort imports using `isort`.
Remove unused imports.
Collect multiple imports from the same module into a single import
statement.
Unify import style.
2024-10-31 16:48:20 +00:00

26 lines
714 B
Python

import os
from clang.cindex import Config, Index, TranslationUnit
if "CLANG_LIBRARY_PATH" in os.environ:
Config.set_library_path(os.environ["CLANG_LIBRARY_PATH"])
import unittest
kInputsDir = os.path.join(os.path.dirname(__file__), "INPUTS")
class TestIndex(unittest.TestCase):
def test_create(self):
Index.create()
# FIXME: test Index.read
def test_parse(self):
index = Index.create()
self.assertIsInstance(index, Index)
tu = index.parse(os.path.join(kInputsDir, "hello.cpp"))
self.assertIsInstance(tu, TranslationUnit)
tu = index.parse(None, ["-c", os.path.join(kInputsDir, "hello.cpp")])
self.assertIsInstance(tu, TranslationUnit)