[英]pytest is not running conftest.py to pick up custom command args
In a project im working on we have a step where we export a csv before exporting we run a regression test step against the report using pytest.在我正在进行的一个项目中,我们有一个步骤,我们在导出之前导出一个 csv,我们使用 pytest 对报告运行回归测试步骤。 pytest is invoked using the following command
pytest 使用以下命令调用
def _invoke_pytest(self):
pytest.main(['src/tests/regression/regression_tests.py'
,"-m",self.expectations_suite
,'--sample', self.sample_filepath
,'--expectations',self.expectations_suite_filepath
,'--report-log',self.logs_report_filepath])
--sample and --expectations are custom args defined in the conftest.py using the following --sample 和 --expectations 是在 conftest.py 中使用以下定义的自定义参数
def pytest_addoption(parser):
parser.addoption("--sample", default=False)
parser.addoption("--expectations", default=False)
when calling this code locally it works pytest finds the conf but when inside a docker container it doesnt pick up the conftest and therefore fails on running pytest.当在本地调用此代码时,它可以工作 pytest 找到 conf,但是当在 docker 容器内时,它不会获取 conftest,因此在运行 pytest 时失败。 a simplified folder layout is as follows
一个简化的文件夹布局如下
src/
├─ main/
│ ├─ export
│ ├─ invoke_pytest
├─ test/
│ ├─ regression/
│ │ ├─ conftest
any help would be greatly appreciated, thanks任何帮助将不胜感激,谢谢
通过将 conftest 移动到 src 文件夹中允许 pytest 找到它,该问题已得到解决
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.