Reputation: 221
I have added conftest.py at the same directory level as my test file . The content of my conftest.py :
import pytest
def pytest_addoption(parser):
parser.addoption("--l", action="store", help="Get license value")
@pytest.fixture
def lic(request):
return request.config.getoption("--l")
and following is my test file def
def test(lic):
print "testing license : %s"%lic
assert 0
But i still get following error:
pytest .\source\test_latestLinuxAgent.py --l=test
pytest : usage: pytest [options] [file_or_dir] [file_or_dir] [...]
At line:1 char:1
+ pytest .\source\test_latestLinuxAgent.py --l=test
pytest: error: ambiguous option: --l=test could match --lf, --last-failed
Upvotes: 0
Views: 629
Reputation: 3092
As the response says, --l
option is ambiguous. What does it mean?
Let me explain it with an example. If you have --zaaaa
option, the shortcut for it is --z
. However, there is one condition: --zaaaa
must be the only option starting with z
char. Otherwise, the interpreter does not know which option should be chosen.
You can't define --l
option because there are two options starting with l
char: --lf
and --last-failed
.
I suggest creating non-conflicting option, --license
would be nice.
Upvotes: 1