Alexander Stukowski | 9a110e6 | 2016-11-15 12:38:05 +0100 | [diff] [blame] | 1 | |
Dean Moldovan | bad1740 | 2016-11-20 21:21:54 +0100 | [diff] [blame] | 2 | |
| 3 | def test_docstring_options(): |
Alexander Stukowski | 9a110e6 | 2016-11-15 12:38:05 +0100 | [diff] [blame] | 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__ |