codecamp

pytest fixture-使用来自其他项目的fixture

通常,提供pytest支持的项目将使用入口点,因此只要将这些项目安装到环境中,就可以使用这些​​fixture​​。

如果你想使用来自不使用入口点的项目的​​fixture​​,你可以在你的顶级​​conftest.py​​文件中定义​​pytest_plugins​​来将该模块注册为插件。

假设在我的库中有一些​​fixture​​。你想要在你的应用/测试目录中重复使用它们。

你所需要做的就是在​​app/tests/conftest.py​​中定义​​pytest_plugins​​指向该模块。

pytest_plugins = "mylibrary.fixtures"

这有效地注册了我的库。将​​fixture​​作为一个插件,使其所有​​fixture​​和钩子可用于​app/tests​中的测试。


pytest fixture-重写各种级别的fixture
pytest 核心功能-用属性标记测试函数
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }