Reputation: 21
Can anyone tell me, why I got the attribute error for this code
def pytest_addoption(parser):
Parser.addoption(“—browser”)
def browser(request):
return request.config.getoption(“—browser”)
Upvotes: 0
Views: 1260
Reputation: 491
Based on the code snippet you provided, I assume you're trying to add commandline options to pytest.
As the error says, the Argument object created by Parser.addoption
needs a dest
attribute.
Try using double hyphens, i.e. long options:
def pytest_addoption(parser):
Parser.addoption(“-—browser”)
def browser(request):
return request.config.getoption(“-—browser”)
these get stored as dest
attributes by default by pytest when dest
is not provided.
Upvotes: 2