2 from clang
.cindex
import Config
4 if "CLANG_LIBRARY_PATH" in os
.environ
:
5 Config
.set_library_path(os
.environ
["CLANG_LIBRARY_PATH"])
7 from clang
.cindex
import TranslationUnit
8 from tests
.cindex
.util
import get_cursor
13 class TestComment(unittest
.TestCase
):
14 def test_comment(self
):
32 # make a comment-aware TU
33 tu
= TranslationUnit
.from_source(
37 options
=TranslationUnit
.PARSE_INCLUDE_BRIEF_COMMENTS_IN_CODE_COMPLETION
,
39 test1
= get_cursor(tu
, "test1")
40 self
.assertIsNotNone(test1
, "Could not find test1.")
41 self
.assertTrue(test1
.type.is_pod())
42 raw
= test1
.raw_comment
43 brief
= test1
.brief_comment
44 self
.assertEqual(raw
, """/// Aaa.""")
45 self
.assertEqual(brief
, """Aaa.""")
47 test2
= get_cursor(tu
, "test2")
48 raw
= test2
.raw_comment
49 brief
= test2
.brief_comment
50 self
.assertEqual(raw
, """/// Bbb.\n/// x""")
51 self
.assertEqual(brief
, """Bbb. x""")
53 f
= get_cursor(tu
, "f")
55 brief
= f
.brief_comment
56 self
.assertIsNone(raw
)
57 self
.assertIsNone(brief
)