test_docstring_options.py
Go to the documentation of this file.
1 from __future__ import annotations
2 
3 from pybind11_tests import docstring_options as m
4 
5 
7  # options.disable_function_signatures()
8  assert not m.test_function1.__doc__
9 
10  assert m.test_function2.__doc__ == "A custom docstring"
11 
12  # docstring specified on just the first overload definition:
13  assert m.test_overloaded1.__doc__ == "Overload docstring"
14 
15  # docstring on both overloads:
16  assert m.test_overloaded2.__doc__ == "overload docstring 1\noverload docstring 2"
17 
18  # docstring on only second overload:
19  assert m.test_overloaded3.__doc__ == "Overload docstr"
20 
21  # options.enable_function_signatures()
22  assert m.test_function3.__doc__.startswith("test_function3(a: int, b: int) -> None")
23 
24  assert m.test_function4.__doc__.startswith("test_function4(a: int, b: int) -> None")
25  assert m.test_function4.__doc__.endswith("A custom docstring\n")
26 
27  # options.disable_function_signatures()
28  # options.disable_user_defined_docstrings()
29  assert not m.test_function5.__doc__
30 
31  # nested options.enable_user_defined_docstrings()
32  assert m.test_function6.__doc__ == "A custom docstring"
33 
34  # RAII destructor
35  assert m.test_function7.__doc__.startswith("test_function7(a: int, b: int) -> None")
36  assert m.test_function7.__doc__.endswith("A custom docstring\n")
37 
38  # when all options are disabled, no docstring (instead of an empty one) should be generated
39  assert m.test_function8.__doc__ is None
40 
41  # Suppression of user-defined docstrings for non-function objects
42  assert not m.DocstringTestFoo.__doc__
43  assert not m.DocstringTestFoo.value_prop.__doc__
44 
45  # Check existig behaviour of enum docstings
46  assert (
47  m.DocstringTestEnum1.__doc__
48  == "Enum docstring\n\nMembers:\n\n Member1\n\n Member2"
49  )
50 
51  # options.enable_enum_members_docstring()
52  assert (
53  m.DocstringTestEnum2.__doc__
54  == "Enum docstring\n\nMembers:\n\n Member1\n\n Member2"
55  )
56 
57  # options.disable_enum_members_docstring()
58  assert m.DocstringTestEnum3.__doc__ == "Enum docstring"
59 
60  # options.disable_user_defined_docstrings()
61  assert m.DocstringTestEnum4.__doc__ == "Members:\n\n Member1\n\n Member2"
62 
63  # options.disable_user_defined_docstrings()
64  # options.disable_enum_members_docstring()
65  # When all options are disabled, no docstring (instead of an empty one) should be generated
66  assert m.DocstringTestEnum5.__doc__ is None
test_docstring_options.test_docstring_options
def test_docstring_options()
Definition: test_docstring_options.py:6


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:39:27