简体   繁体   中英

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. pytest is invoked using the following command

    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

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. 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 找到它,该问题已得到解决

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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