Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
singlestore-labs
GitHub Repository: singlestore-labs/singlestoredb-python
Path: blob/main/singlestoredb/docstring/tests/test_util.py
469 views
1
"""Test for utility functions."""
2
from typing import Any
3
4
from singlestoredb.docstring.common import DocstringReturns
5
from singlestoredb.docstring.util import combine_docstrings
6
7
8
def test_combine_docstrings() -> None:
9
"""Test combine_docstrings wrapper."""
10
11
def fun1(arg_a: Any, arg_b: Any, arg_c: Any, arg_d: Any) -> None:
12
"""short_description: fun1
13
14
:param arg_a: fun1
15
:param arg_b: fun1
16
:return: fun1
17
"""
18
assert arg_a and arg_b and arg_c and arg_d
19
20
def fun2(arg_b: Any, arg_c: Any, arg_d: Any, arg_e: Any) -> None:
21
"""short_description: fun2
22
23
long_description: fun2
24
25
:param arg_b: fun2
26
:param arg_c: fun2
27
:param arg_e: fun2
28
"""
29
assert arg_b and arg_c and arg_d and arg_e
30
31
@combine_docstrings(fun1, fun2)
32
def decorated1(
33
arg_a: Any, arg_b: Any, arg_c: Any,
34
arg_d: Any, arg_e: Any, arg_f: Any,
35
) -> None:
36
"""
37
:param arg_e: decorated
38
:param arg_f: decorated
39
"""
40
assert arg_a and arg_b and arg_c and arg_d and arg_e and arg_f
41
42
assert decorated1.__doc__ == (
43
'short_description: fun2\n'
44
'\n'
45
'long_description: fun2\n'
46
'\n'
47
':param arg_a: fun1\n'
48
':param arg_b: fun1\n'
49
':param arg_c: fun2\n'
50
':param arg_e: fun2\n'
51
':param arg_f: decorated\n'
52
':returns: fun1'
53
)
54
55
@combine_docstrings(fun1, fun2, exclude=[DocstringReturns])
56
def decorated2(
57
arg_a: Any, arg_b: Any, arg_c: Any, arg_d: Any, arg_e: Any, arg_f: Any,
58
) -> None:
59
assert arg_a and arg_b and arg_c and arg_d and arg_e and arg_f
60
61
assert decorated2.__doc__ == (
62
'short_description: fun2\n'
63
'\n'
64
'long_description: fun2\n'
65
'\n'
66
':param arg_a: fun1\n'
67
':param arg_b: fun1\n'
68
':param arg_c: fun2\n'
69
':param arg_e: fun2'
70
)
71
72