Branch data Line data Source code
1 : : #include "parts.h"
2 : :
3 : :
4 : : PyDoc_STRVAR(docstring_empty,
5 : : ""
6 : : );
7 : :
8 : : PyDoc_STRVAR(docstring_no_signature,
9 : : "This docstring has no signature."
10 : : );
11 : :
12 : : PyDoc_STRVAR(docstring_with_invalid_signature,
13 : : "docstring_with_invalid_signature($module, /, boo)\n"
14 : : "\n"
15 : : "This docstring has an invalid signature."
16 : : );
17 : :
18 : : PyDoc_STRVAR(docstring_with_invalid_signature2,
19 : : "docstring_with_invalid_signature2($module, /, boo)\n"
20 : : "\n"
21 : : "--\n"
22 : : "\n"
23 : : "This docstring also has an invalid signature."
24 : : );
25 : :
26 : : PyDoc_STRVAR(docstring_with_signature,
27 : : "docstring_with_signature($module, /, sig)\n"
28 : : "--\n"
29 : : "\n"
30 : : "This docstring has a valid signature."
31 : : );
32 : :
33 : : PyDoc_STRVAR(docstring_with_signature_but_no_doc,
34 : : "docstring_with_signature_but_no_doc($module, /, sig)\n"
35 : : "--\n"
36 : : "\n"
37 : : );
38 : :
39 : : PyDoc_STRVAR(docstring_with_signature_and_extra_newlines,
40 : : "docstring_with_signature_and_extra_newlines($module, /, parameter)\n"
41 : : "--\n"
42 : : "\n"
43 : : "\n"
44 : : "This docstring has a valid signature and some extra newlines."
45 : : );
46 : :
47 : : PyDoc_STRVAR(docstring_with_signature_with_defaults,
48 : : "docstring_with_signature_with_defaults(module, s='avocado',\n"
49 : : " b=b'bytes', d=3.14, i=35, n=None, t=True, f=False,\n"
50 : : " local=the_number_three, sys=sys.maxsize,\n"
51 : : " exp=sys.maxsize - 1)\n"
52 : : "--\n"
53 : : "\n"
54 : : "\n"
55 : : "\n"
56 : : "This docstring has a valid signature with parameters,\n"
57 : : "and the parameters take defaults of varying types."
58 : : );
59 : :
60 : : /* This is here to provide a docstring for test_descr. */
61 : : static PyObject *
62 : 0 : test_with_docstring(PyObject *self, PyObject *Py_UNUSED(ignored))
63 : : {
64 : 0 : Py_RETURN_NONE;
65 : : }
66 : :
67 : : static PyMethodDef test_methods[] = {
68 : : {"docstring_empty",
69 : : (PyCFunction)test_with_docstring, METH_NOARGS,
70 : : docstring_empty},
71 : : {"docstring_no_signature",
72 : : (PyCFunction)test_with_docstring, METH_NOARGS,
73 : : docstring_no_signature},
74 : : {"docstring_with_invalid_signature",
75 : : (PyCFunction)test_with_docstring, METH_NOARGS,
76 : : docstring_with_invalid_signature},
77 : : {"docstring_with_invalid_signature2",
78 : : (PyCFunction)test_with_docstring, METH_NOARGS,
79 : : docstring_with_invalid_signature2},
80 : : {"docstring_with_signature",
81 : : (PyCFunction)test_with_docstring, METH_NOARGS,
82 : : docstring_with_signature},
83 : : {"docstring_with_signature_and_extra_newlines",
84 : : (PyCFunction)test_with_docstring, METH_NOARGS,
85 : : docstring_with_signature_and_extra_newlines},
86 : : {"docstring_with_signature_but_no_doc",
87 : : (PyCFunction)test_with_docstring, METH_NOARGS,
88 : : docstring_with_signature_but_no_doc},
89 : : {"docstring_with_signature_with_defaults",
90 : : (PyCFunction)test_with_docstring, METH_NOARGS,
91 : : docstring_with_signature_with_defaults},
92 : : {"no_docstring",
93 : : (PyCFunction)test_with_docstring, METH_NOARGS},
94 : : {"test_with_docstring",
95 : : test_with_docstring, METH_NOARGS,
96 : : PyDoc_STR("This is a pretty normal docstring.")},
97 : : {NULL},
98 : : };
99 : :
100 : : int
101 : 2 : _PyTestCapi_Init_Docstring(PyObject *mod)
102 : : {
103 [ - + ]: 2 : if (PyModule_AddFunctions(mod, test_methods) < 0) {
104 : 0 : return -1;
105 : : }
106 : 2 : return 0;
107 : : }
|