#include "test_case.h"

void test_CallModuleFunction() {
    printf("=======> test funtion %s come in <========\r\n", __FUNCTION__);

    Py_Initialize();
    getCurrentEnv();

    PyObject *pModule = NULL, *pFunc = NULL, *pArg = NULL;
    pModule = PyImport_ImportModule("demo");                // 引入模块
    pFunc = PyObject_GetAttrString(pModule, "print_arg");   // 直接获取模块中的函数
    pArg = Py_BuildValue("(s)", "hello_python");            // 參数类型转换,传递一个字符串。将c/c++类型的字符串转换为python类型。元组中的python类型查看python文档
    PyEval_CallObject(pFunc, pArg);                         // 调用直接获得的函数。并传递參数

    Py_Finalize();

    printf("=======> test funtion %s leave out <========\r\n\r\n\r\n", __FUNCTION__);
    return;
}