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