簡體   English   中英

pytest 沒有運行 conftest.py 來獲取自定義命令參數

[英]pytest is not running conftest.py to pick up custom command args

在我正在進行的一個項目中,我們有一個步驟,我們在導出之前導出一個 csv,我們使用 pytest 對報告運行回歸測試步驟。 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 和 --expectations 是在 conftest.py 中使用以下定義的自定義參數

def pytest_addoption(parser):
    parser.addoption("--sample", default=False)
    parser.addoption("--expectations", default=False)

當在本地調用此代碼時,它可以工作 pytest 找到 conf,但是當在 docker 容器內時,它不會獲取 conftest,因此在運行 pytest 時失敗。 一個簡化的文件夾布局如下

src/
├─ main/
│  ├─ export
│  ├─ invoke_pytest
├─ test/
│  ├─ regression/
│  │  ├─ conftest

任何幫助將不勝感激,謝謝

通過將 conftest 移動到 src 文件夾中允許 pytest 找到它,該問題已得到解決

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM