You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.2 KiB

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