Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:53

0001 from pybind11_tests import docstring_options as m
0002 
0003 
0004 def test_docstring_options():
0005     # options.disable_function_signatures()
0006     assert not m.test_function1.__doc__
0007 
0008     assert m.test_function2.__doc__ == "A custom docstring"
0009 
0010     # docstring specified on just the first overload definition:
0011     assert m.test_overloaded1.__doc__ == "Overload docstring"
0012 
0013     # docstring on both overloads:
0014     assert m.test_overloaded2.__doc__ == "overload docstring 1\noverload docstring 2"
0015 
0016     # docstring on only second overload:
0017     assert m.test_overloaded3.__doc__ == "Overload docstr"
0018 
0019     # options.enable_function_signatures()
0020     assert m.test_function3.__doc__.startswith("test_function3(a: int, b: int) -> None")
0021 
0022     assert m.test_function4.__doc__.startswith("test_function4(a: int, b: int) -> None")
0023     assert m.test_function4.__doc__.endswith("A custom docstring\n")
0024 
0025     # options.disable_function_signatures()
0026     # options.disable_user_defined_docstrings()
0027     assert not m.test_function5.__doc__
0028 
0029     # nested options.enable_user_defined_docstrings()
0030     assert m.test_function6.__doc__ == "A custom docstring"
0031 
0032     # RAII destructor
0033     assert m.test_function7.__doc__.startswith("test_function7(a: int, b: int) -> None")
0034     assert m.test_function7.__doc__.endswith("A custom docstring\n")
0035 
0036     # when all options are disabled, no docstring (instead of an empty one) should be generated
0037     assert m.test_function8.__doc__ is None
0038 
0039     # Suppression of user-defined docstrings for non-function objects
0040     assert not m.DocstringTestFoo.__doc__
0041     assert not m.DocstringTestFoo.value_prop.__doc__
0042 
0043     # Check existig behaviour of enum docstings
0044     assert (
0045         m.DocstringTestEnum1.__doc__
0046         == "Enum docstring\n\nMembers:\n\n  Member1\n\n  Member2"
0047     )
0048 
0049     # options.enable_enum_members_docstring()
0050     assert (
0051         m.DocstringTestEnum2.__doc__
0052         == "Enum docstring\n\nMembers:\n\n  Member1\n\n  Member2"
0053     )
0054 
0055     # options.disable_enum_members_docstring()
0056     assert m.DocstringTestEnum3.__doc__ == "Enum docstring"
0057 
0058     # options.disable_user_defined_docstrings()
0059     assert m.DocstringTestEnum4.__doc__ == "Members:\n\n  Member1\n\n  Member2"
0060 
0061     # options.disable_user_defined_docstrings()
0062     # options.disable_enum_members_docstring()
0063     # When all options are disabled, no docstring (instead of an empty one) should be generated
0064     assert m.DocstringTestEnum5.__doc__ is None