繁体   English   中英

Flask:使用 pytest 夹具注入“client”参数

[英]Flask: injection of the "client" parameter using pytest fixture

我只是无法弄清楚 pytest 如何确定位于此文件中的 Flask 测试套件中的参数“client”。

class SwaggerTest(object):
    def test_specs_endpoint(self, api, client):
        data = client.get_specs("")
        assert data["swagger"] == "2.0"
        assert data["basePath"] == "/"
        assert data["produces"] == ["application/json"]
        assert data["consumes"] == ["application/json"]
        assert data["paths"] == {}
        assert "info" in data

我查看了同一目录中的 conftest.py 文件,但没有定义“客户端”的夹具。

谢谢你的帮助。

当我看到一个正在使用的夹具时,我和你一样的第一反应是检查conftest.py文件。 由于那里没有定义,我的下一个想法是检查导致我进入这一行的测试要求。 在找到pytest-flask的文档后,我们可以看到这个夹具client被定义为该库中的夹具。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM