1 Star 0 Fork 76

飞扬在线/FastAPI

forked from Gitee 极速下载/FastAPI 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test_param_class.py 604 Bytes
一键复制 编辑 原始数据 按行查看 历史
from fastapi import FastAPI
from fastapi.params import Param
from fastapi.testclient import TestClient
app = FastAPI()
@app.get("/items/")
def read_items(q: str | None = Param(default=None)): # type: ignore
return {"q": q}
client = TestClient(app)
def test_default_param_query_none():
response = client.get("/items/")
assert response.status_code == 200, response.text
assert response.json() == {"q": None}
def test_default_param_query():
response = client.get("/items/?q=foo")
assert response.status_code == 200, response.text
assert response.json() == {"q": "foo"}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/dccal/FastAPI.git
git@gitee.com:dccal/FastAPI.git
dccal
FastAPI
FastAPI
master

搜索帮助