小编Pro*_*sor的帖子

pytest 夹具产量返回生成器而不是对象

我正在运行 pytest-3。我正在定义一个应该返回 falcon TestClient 对象的装置。我还需要拆解,所以我正在努力放弃它。

def client():
    api=create_app()
    c = testing.TestClient(api)
    yield c
    remove_db()
Run Code Online (Sandbox Code Playgroud)

如果我“返回”而不是“yield”,则测试用例运行得很好。但是通过收益,我的测试用例得到一个生成器对象而不是 TestClient 对象

pytest python-3.x falconframework

5
推荐指数
1
解决办法
6000
查看次数

标签 统计

falconframework ×1

pytest ×1

python-3.x ×1