[英]Why I am getting 'pytest: error: unrecognized arguments: --env=qa' when running multiple pytest commands in a bash script
該死的,
1.
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --env=qa
inifile: /*/*/projects/<root dir>/pytest.ini
rootdir: /*/*/projects/<root dir>
元數據:{'Python':'3.8.3','平台':'Linux-4.4.0-184-generic-x86_64-with-glibc2.17','包':{'pytest':'7.2.0 ',...}
**conftest.py**:
def pytest_addoption(parser):
parser.addoption("--env", action="store", help="Environments: qa, staging, prod")
項目目錄結構
├── roster
│ ├── __init__.py
│ ├── conftest.py
│ ├── run_suite_jenkins.sh
│ ├── smoke
│ └── utils.py
**可執行的 bash 腳本有多個這樣的命令: run_suite_jenkins.sh :
pytest roster/smoke/tests/test_team.py --env=qa --alluredir allure-results
pytest roster/smoke/tests/test_account_access.py --env=qa --alluredir allure-results
pytest roster/smoke/tests/test_brand.py --env=qa --alluredir allure-results
pytest roster/smoke/tests/test_company.py --env=qa --alluredir allure-results
.....
.....
.....
我這樣執行腳本: $./roster/run_suite_jenkins.sh
僅供參考。 我知道我可以只用這個命令運行測試,但我們有理由不這樣做。
pytest roster/smoke/tests/ --env=qa --alluredir allure-results
任何幫助將不勝感激。 謝謝
該文檔解釋了為什么這不起作用。 它指出:
由於 pytest 在啟動期間發現插件的方式,此 function 應僅在位於測試根目錄的插件或 conftest.py 文件中實現。
根據您顯示的存儲庫結構圖, conftest.py
文件不在tests
目錄的根目錄中。 把它移到那里再試一次。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.