5
我有一個項目目錄看起來像以下py.test:錯誤:無法識別參數
Projects/
....this_project/
........this_project/
............__init__.py
............code.py
............tests/
................conftest.py
................test_1.py
................test_2.py
,我通過將以下代碼到conftest.py添加命令行選項(--PALLADIUM_CONFIG)
def pytest_addoption(parser):
parser.addoption("--PALLADIUM_CONFIG", action="store")
@pytest.fixture
def PALLADIUM_CONFIG(request):
return request.config.getoption("--PALLADIUM_CONFIG")
什麼奇怪的是:
如果我cd到
Projects/this_project/this_project
或
Projects/this_project/this_project/tests
和運行
py.test --PALLADIUM_CONFIG=***
如果運行良好
但如果我找到自己在例如
Projects/this_project
或
Projects
然後pytest給了我錯誤
py.test: error: unrecognized arguments: --PALLADIUM_CONFIG=***