test_docstring_options.py revision 11986:c12e4625ab56
1
2
3def test_docstring_options():
4    from pybind11_tests import (test_function1, test_function2, test_function3,
5                                test_function4, test_function5, test_function6,
6                                test_function7, DocstringTestFoo)
7
8    # options.disable_function_signatures()
9    assert not test_function1.__doc__
10
11    assert test_function2.__doc__ == "A custom docstring"
12
13    # options.enable_function_signatures()
14    assert test_function3.__doc__ .startswith("test_function3(a: int, b: int) -> None")
15
16    assert test_function4.__doc__ .startswith("test_function4(a: int, b: int) -> None")
17    assert test_function4.__doc__ .endswith("A custom docstring\n")
18
19    # options.disable_function_signatures()
20    # options.disable_user_defined_docstrings()
21    assert not test_function5.__doc__
22
23    # nested options.enable_user_defined_docstrings()
24    assert test_function6.__doc__ == "A custom docstring"
25
26    # RAII destructor
27    assert test_function7.__doc__ .startswith("test_function7(a: int, b: int) -> None")
28    assert test_function7.__doc__ .endswith("A custom docstring\n")
29
30    # Suppression of user-defined docstrings for non-function objects
31    assert not DocstringTestFoo.__doc__
32    assert not DocstringTestFoo.value_prop.__doc__
33