我正在运行pytest-3。我正在定义一个fixture,它应该返回一个猎鹰TestClient对象。我也需要一个拆卸,所以我试着让它。
def client():
api=create_app()
c = testing.TestClient(api)
yield c
remove_db()如果我“返回”而不是“放弃”,测试用例就会运行得很好。但是有了test,我的测试用例就会得到一个生成器对象,而不是TestClient对象
发布于 2019-02-27 00:23:08
可能是因为函数没有标记为fixture。在使用@pytest.fixture修饰函数之后尝试。例如,
@pytest.fixture(scope="session")
def client():
api=create_app()
c = testing.TestClient(api)
yield c
remove_db()https://stackoverflow.com/questions/54887336
复制相似问题