test_docstring_options.py 1.46 KB
Newer Older
1
# -*- coding: utf-8 -*-
2
from pybind11_tests import docstring_options as m
3

4
5

def test_docstring_options():
6
    # options.disable_function_signatures()
7
    assert not m.test_function1.__doc__
8

9
    assert m.test_function2.__doc__ == "A custom docstring"
10

11
    # docstring specified on just the first overload definition:
12
    assert m.test_overloaded1.__doc__ == "Overload docstring"
13
14

    # docstring on both overloads:
15
    assert m.test_overloaded2.__doc__ == "overload docstring 1\noverload docstring 2"
16
17

    # docstring on only second overload:
18
    assert m.test_overloaded3.__doc__ == "Overload docstr"
19

20
    # options.enable_function_signatures()
21
    assert m.test_function3.__doc__ .startswith("test_function3(a: int, b: int) -> None")
22

23
24
    assert m.test_function4.__doc__ .startswith("test_function4(a: int, b: int) -> None")
    assert m.test_function4.__doc__ .endswith("A custom docstring\n")
25
26
27

    # options.disable_function_signatures()
    # options.disable_user_defined_docstrings()
28
    assert not m.test_function5.__doc__
29
30

    # nested options.enable_user_defined_docstrings()
31
    assert m.test_function6.__doc__ == "A custom docstring"
32
33

    # RAII destructor
34
35
    assert m.test_function7.__doc__ .startswith("test_function7(a: int, b: int) -> None")
    assert m.test_function7.__doc__ .endswith("A custom docstring\n")
36
37

    # Suppression of user-defined docstrings for non-function objects
38
39
    assert not m.DocstringTestFoo.__doc__
    assert not m.DocstringTestFoo.value_prop.__doc__