Commit d673830a authored by wanli's avatar wanli

🧪 test: 更新测试用例

parent 8b380051
Pipeline #586 failed with stages
......@@ -16,10 +16,13 @@ SOURCES += \
test_CallPythonFunction.c \
test_CallPythonSentiment.c \
test_CallScript.c \
test_RunSimpleString.c
test_RunSimpleString.c \
test_StartServer.c
DISTFILES += \
fastapi_main.py \
graph.py \
hello.py \
sample.py \
demo.py \
multiply.py \
......
import json
import uvicorn
from typing import Optional
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
return {"item_id": item_id, "q": q}
@app.get("/json")
def get_json():
result = { "xxx": "started by cpython" }
if result:
result = json.loads(result)
return result
def start_server():
print("start web service....")
uvicorn.run(app='fastapi_main:app', host="0.0.0.0", port=58000, reload=True, log_level="info", workers=1)
if __name__ == '__main__':
start_server()
......@@ -3,7 +3,7 @@ import xlsxwriter
def create_graph(a, b, c, d, e, f):
# 创建一个excel
# 创建一个excel
workbook = xlsxwriter.Workbook("排序算法比较结果.xlsx")
# 创建一个sheet
worksheet = workbook.add_worksheet()
......@@ -49,5 +49,6 @@ def create_graph(a, b, c, d, e, f):
workbook.close()
return 0
if __name__ == "__main__":
create_graph(10, 40, 50, 20, 10, 50)
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello, World!'
def start():
app.run()
if __name__ == '__main__':
start()
\ No newline at end of file
......@@ -22,6 +22,7 @@ int main(int argc, const char* argv[])
test_CallModuleClass(); // 调用模块中简单的一个类(单个返回值)
test_CallModuleClassReturnTuple(); // 调用模块中一个简单的类(返回值是个元组)
test_CallScript(); // 调用一个python脚本
test_StartServer();
system("PAUSE");
return 0;
......
#include "test_case.h"
void test_StartServer() {
Py_Initialize();
getCurrentEnv();
PyObject* pModule = NULL, *pMethod = NULL, *pArg = NULL;
pModule = PyImport_ImportModule("hello");
pMethod = PyObject_GetAttrString(pModule, "start");
pArg = Py_BuildValue("()", NULL);
PyEval_CallObject(pMethod, pArg);
printf("is blocked ???");
Py_Finalize();
}
......@@ -11,6 +11,7 @@ void test_CallModuleFunctionByParameters(void);
void test_CallModuleClass(void);
void test_CallScript(void);
void test_CallModuleClassReturnTuple(void);
void test_StartServer(void);
float getSentiment(char* sentence);
void getCurrentEnv();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment