Python: add load test to limited API test
Based on the example in GH issue #13167, the limited API test has been extended with a test to load the compiled module to ensure it can be loaded correctly.
This commit is contained in:
parent
141100e482
commit
d1abdce88f
|
@ -6,12 +6,22 @@
|
|||
#error Wrong value for Py_LIMITED_API
|
||||
#endif
|
||||
|
||||
static PyObject *
|
||||
hello(PyObject * Py_UNUSED(self), PyObject * Py_UNUSED(args)) {
|
||||
return PyUnicode_FromString("hello world");
|
||||
}
|
||||
|
||||
static struct PyMethodDef methods[] = {
|
||||
{ "hello", hello, METH_NOARGS, NULL },
|
||||
{ NULL, NULL, 0, NULL },
|
||||
};
|
||||
|
||||
static struct PyModuleDef limited_module = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"limited_api_test",
|
||||
"limited",
|
||||
NULL,
|
||||
-1,
|
||||
NULL
|
||||
methods
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC PyInit_limited(void) {
|
||||
|
|
|
@ -14,3 +14,10 @@ ext_mod = py.extension_module('not_limited',
|
|||
'not_limited.c',
|
||||
install: true,
|
||||
)
|
||||
|
||||
test('load-test',
|
||||
py,
|
||||
args: [files('test_limited.py')],
|
||||
env: { 'PYTHONPATH': meson.current_build_dir() },
|
||||
workdir: meson.current_source_dir()
|
||||
)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
from limited import hello
|
||||
|
||||
def test_hello():
|
||||
assert hello() == "hello world"
|
||||
|
||||
test_hello()
|
Loading…
Reference in New Issue