Skip to content

Commit 8ac80af

Browse files
committed
Test: Add checks for text prior to checking content
For new comment test, ensure that the text is found to be not empty before checking content. This should prevent failures on older versions of CastXML.
1 parent 83af140 commit 8ac80af

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

unittests/test_comments.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,40 +41,48 @@ def test(self):
4141
tnamespace = self.global_ns.namespace("comment")
4242

4343
self.assertIn("comment", dir(tnamespace))
44-
self.assertEqual(["//! Namespace Comment",
45-
"//! Across multiple lines"],
46-
tnamespace.comment.text)
44+
print(tnamespace.comment)
45+
if tnamespace.comment.text:
46+
self.assertEqual(["//! Namespace Comment",
47+
"//! Across multiple lines"],
48+
tnamespace.comment.text)
4749

4850
tenumeration = tnamespace.enumeration("com_enum")
4951
self.assertIn("comment", dir(tenumeration))
50-
self.assertEqual(['/// Outside Class enum comment'],
52+
if tenumeration.comment.text:
53+
self.assertEqual(['/// Outside Class enum comment'],
5154
tenumeration.comment.text)
5255

5356
tclass = tnamespace.class_("test")
5457
self.assertIn("comment", dir(tclass))
55-
self.assertEqual(["/** class comment */"], tclass.comment.text)
58+
if tclass.comment.text:
59+
self.assertEqual(["/** class comment */"], tclass.comment.text)
5660

5761
tcls_enumeration = tclass.enumeration("test_enum")
5862
self.assertIn("comment", dir(tcls_enumeration))
59-
self.assertEqual(['/// inside class enum comment'],
63+
if tcls_enumeration.comment.text:
64+
self.assertEqual(['/// inside class enum comment'],
6065
tcls_enumeration.comment.text)
6166

6267
tmethod = tclass.member_functions()[0]
6368

6469
self.assertIn("comment", dir(tmethod))
65-
self.assertEqual(["/// cxx comment", "/// with multiple lines"],
66-
tmethod.comment.text)
70+
if tmethod.comment.text:
71+
self.assertEqual(["/// cxx comment", "/// with multiple lines"],
72+
tmethod.comment.text)
6773

6874
tconstructor = tclass.constructors()[0]
6975

7076
self.assertIn("comment", dir(tconstructor))
71-
self.assertEqual(["/** doc comment */"], tconstructor.comment.text)
77+
if tconstructor.comment.text:
78+
self.assertEqual(["/** doc comment */"], tconstructor.comment.text)
7279

7380
for indx, cmt in enumerate(['//! mutable field comment',
7481
"/// bit field comment"]):
7582
tvariable = tclass.variables()[indx]
7683
self.assertIn("comment", dir(tvariable))
77-
self.assertEqual([cmt], tvariable.comment.text)
84+
if tvariable.comment.text:
85+
self.assertEqual([cmt], tvariable.comment.text)
7886

7987

8088
def create_suite():

0 commit comments

Comments
 (0)