美文网首页
pytest的fixtures学习七

pytest的fixtures学习七

作者: 小源宝1573 | 来源:发表于2020-07-07 09:38 被阅读0次

fixtures可以自检请求的测试上下文

fixtures函数可以接受request对象来自检“requesting”测试函数、类或模块上下文。进一步扩展之前的smtp_connection示例,从使用的测试模块中读取一个可选的服务器URL:

官网示例

我们使用request.module属性从测试模块中选择获取smtpserver属性,如果再次执行,什么都不变:

官网示例 测试模块

创建另一个测试模块,该模块实际上在其模块命名空间中增加了服务器URL设置:

官网示例

执行结果:

官网示例

可以看出,smtp_connection 函数从模块命名空间中获取的邮件服务器名称。

相关文章

  • pytest的fixtures学习七

    fixtures可以自检请求的测试上下文 fixtures函数可以接受request对象来自检“requestin...

  • pytest的fixture学习一

    主要从官网上面学习。 pytest fixtures: 显示化、模块化、可扩展 软件测试fixtures初始化测试...

  • Pytest Fixture

    关于pytest fixtures,根据官方文档[https://docs.pytest.org/en/7.1.x...

  • [译]pytest文档第5章

    Chapter 5 pytest fixtures: explicit, modular, scalable py...

  • pytest的fixtures学习十一

    参数化fixture(二) 在上一篇“十”中最后运行的结果可以看到,两个测试函数针对不同的smtp_connect...

  • pytest的fixtures学习九

    factories作为fixtures factories作为fixtures 模式可以在单个测试中,多次需要fi...

  • pytest的fixtures学习十

    参数化fixture(一) fixture函数可以进行参数化设置,在这种情况下,每次执行一组测试用例,fixtur...

  • pytest的fixtures学习八

    使用markers传递数据给fixtures 使用request对象,fixture也可以访问应用于测试函数的ma...

  • pytest探究(2):fixtures

    pytest 的 fixtures 基于 xUnit 的 setup/teardown 风格,可对测试进行前置处理...

  • _fixtures

    其实我超喜欢pytest的fixtures windows下文件描述①filename = 'E:\testres...

网友评论

      本文标题:pytest的fixtures学习七

      本文链接:https://www.haomeiwen.com/subject/bdnoqktx.html