Switch Python Doxygen unit tests to use inspect.getdoc()
Using the standard inspect module instead of accessing __doc__ directly allows
the tests to pass both when using and not using -builtin, as whitespace-only
differences between the docstrings don't matter then because inspect.getdoc()
removes the indentation and the leading and trailing spaces.
This is similar to what had been already done for python_docstring unit test
in fa282b3540.
This commit is contained in:
parent
e668c47b70
commit
148bcab7a0
8 changed files with 171 additions and 244 deletions
|
|
@ -1,72 +1,64 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import doxygen_parsing
|
||||
import inspect
|
||||
import string
|
||||
import os
|
||||
import sys
|
||||
import commentVerifier
|
||||
|
||||
commentVerifier.check(doxygen_parsing.someFunction.__doc__,
|
||||
r"""
|
||||
The function comment""")
|
||||
commentVerifier.check(doxygen_parsing.SomeClass.__doc__,
|
||||
r"""
|
||||
The class comment""")
|
||||
commentVerifier.check(doxygen_parsing.SomeStruct.__doc__,
|
||||
r"""
|
||||
The struct comment""")
|
||||
commentVerifier.check(inspect.getdoc(doxygen_parsing.someFunction),
|
||||
"The function comment")
|
||||
commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeClass),
|
||||
"The class comment")
|
||||
commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeStruct),
|
||||
"The struct comment")
|
||||
|
||||
# There doesn't seem to be any way to specify the doc string for __init__ when
|
||||
# using "-builtin" (see http://stackoverflow.com/q/11913492/15275), so skip
|
||||
# this test in this case.
|
||||
if str(os.environ.get('SWIG_FEATURES')).find('-builtin') == -1:
|
||||
commentVerifier.check(doxygen_parsing.SomeAnotherClass.__init__.__doc__,
|
||||
r""" *Overload 1:*
|
||||
First overloaded constructor.
|
||||
commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.__init__),
|
||||
r"""*Overload 1:*
|
||||
First overloaded constructor.
|
||||
|
||||
|
|
||||
|
|
||||
|
||||
*Overload 2:*
|
||||
Second overloaded constructor.""")
|
||||
*Overload 2:*
|
||||
Second overloaded constructor.""")
|
||||
|
||||
commentVerifier.check(doxygen_parsing.SomeAnotherClass.classMethod.__doc__,
|
||||
r"""
|
||||
The class method comment.
|
||||
commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMethod),
|
||||
r"""The class method comment.
|
||||
|
||||
SomeAnotherClass#classMethodExtended(int, int) a link text""")
|
||||
commentVerifier.check(doxygen_parsing.SomeAnotherClass.classMethodExtended.__doc__,
|
||||
r"""
|
||||
The class method with parameter
|
||||
commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMethodExtended),
|
||||
r"""The class method with parameter
|
||||
|
||||
:type a: int
|
||||
:param a: Parameter a
|
||||
:type b: int
|
||||
:param b: Parameter b"""
|
||||
)
|
||||
commentVerifier.check(doxygen_parsing.SomeAnotherClass.classMethodExtended2.__doc__,
|
||||
r"""
|
||||
The class method with parameter
|
||||
commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMethodExtended2),
|
||||
r"""The class method with parameter
|
||||
|
||||
:type a: int
|
||||
:param a: Parameter a
|
||||
:type b: int
|
||||
:param b: Parameter b"""
|
||||
)
|
||||
commentVerifier.check(doxygen_parsing.SomeAnotherStruct.structMethod.__doc__,
|
||||
r"""
|
||||
The struct method comment""")
|
||||
commentVerifier.check(doxygen_parsing.SomeAnotherStruct.structMethodExtended.__doc__,
|
||||
r"""
|
||||
The struct method with parameter
|
||||
commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMethod),
|
||||
r"""The struct method comment""")
|
||||
commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMethodExtended),
|
||||
r"""The struct method with parameter
|
||||
|
||||
:type a: int
|
||||
:param a: Parameter a
|
||||
:type b: int
|
||||
:param b: Parameter b"""
|
||||
)
|
||||
commentVerifier.check(doxygen_parsing.SomeAnotherStruct.structMethodExtended2.__doc__,
|
||||
r"""
|
||||
The struct method with parameter
|
||||
commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMethodExtended2),
|
||||
r"""The struct method with parameter
|
||||
|
||||
:type a: int
|
||||
:param a: Parameter a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue