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,74 +1,65 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import doxygen_basic_notranslate
|
||||
import inspect
|
||||
import string
|
||||
import sys
|
||||
import commentVerifier
|
||||
|
||||
commentVerifier.check(doxygen_basic_notranslate.function.__doc__,
|
||||
r"""
|
||||
\brief
|
||||
Brief description.
|
||||
commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function),
|
||||
r"""\brief
|
||||
Brief description.
|
||||
|
||||
The comment text
|
||||
\author Some author
|
||||
\return Some number
|
||||
\sa function2
|
||||
"""
|
||||
The comment text
|
||||
\author Some author
|
||||
\return Some number
|
||||
\sa function2"""
|
||||
)
|
||||
|
||||
commentVerifier.check(doxygen_basic_notranslate.function2.__doc__,
|
||||
r"""
|
||||
A test of a very very very very very very very very very very very very very very very very
|
||||
very very very very very long comment string.
|
||||
"""
|
||||
commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function2),
|
||||
r"""A test of a very very very very very very very very very very very very very very very very
|
||||
very very very very very long comment string."""
|
||||
)
|
||||
|
||||
commentVerifier.check(doxygen_basic_notranslate.function3.__doc__,
|
||||
r""" *Overload 1:*
|
||||
commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function3),
|
||||
r"""*Overload 1:*
|
||||
|
||||
A test for overloaded functions
|
||||
This is function \b one
|
||||
A test for overloaded functions
|
||||
This is function \b one
|
||||
|
||||
|
|
||||
|
|
||||
|
||||
*Overload 2:*
|
||||
*Overload 2:*
|
||||
|
||||
A test for overloaded functions
|
||||
This is function \b two"""
|
||||
A test for overloaded functions
|
||||
This is function \b two"""
|
||||
)
|
||||
|
||||
commentVerifier.check(doxygen_basic_notranslate.function4.__doc__,
|
||||
r"""
|
||||
A test of some mixed tag usage
|
||||
\if CONDITION
|
||||
This \a code fragment shows us something \.
|
||||
\par Minuses:
|
||||
\arg it's senseless
|
||||
\arg it's stupid
|
||||
\arg it's null
|
||||
commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function4),
|
||||
r"""A test of some mixed tag usage
|
||||
\if CONDITION
|
||||
This \a code fragment shows us something \.
|
||||
\par Minuses:
|
||||
\arg it's senseless
|
||||
\arg it's stupid
|
||||
\arg it's null
|
||||
|
||||
\warning This may not work as expected
|
||||
\warning This may not work as expected
|
||||
|
||||
\code
|
||||
int main() { while(true); }
|
||||
\endcode
|
||||
\endif
|
||||
"""
|
||||
\code
|
||||
int main() { while(true); }
|
||||
\endcode
|
||||
\endif"""
|
||||
)
|
||||
commentVerifier.check(doxygen_basic_notranslate.function5.__doc__,
|
||||
r""" This is a post comment. """
|
||||
commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function5),
|
||||
r"""This is a post comment. """
|
||||
)
|
||||
commentVerifier.check(doxygen_basic_notranslate.function6.__doc__,
|
||||
r"""
|
||||
Test for default args
|
||||
@param a Some parameter, default is 42
|
||||
"""
|
||||
commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function6),
|
||||
r"""Test for default args
|
||||
@param a Some parameter, default is 42"""
|
||||
)
|
||||
commentVerifier.check(doxygen_basic_notranslate.function7.__doc__,
|
||||
r"""
|
||||
Test for a parameter with difficult type
|
||||
(mostly for python)
|
||||
@param a Very strange param
|
||||
"""
|
||||
commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function7),
|
||||
r"""Test for a parameter with difficult type
|
||||
(mostly for python)
|
||||
@param a Very strange param"""
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue