Skip to content
Advertisement

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

Advertisement

Answer

the issue was fixed by moving conftest into the src folder allowed pytest to find it

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement