Python, Pytest Is It Possbile To Add Both Long And Short Args?
Solution 1:
I'm not sure why you get this error message. If I do the same, I get:
ValueError: lowercase shortoptions reserved
meaning that pytest
reserves all lower-case option abbreviations to itself, so it is not possible to do what you want. If you want to add an abbreviation, you have to use an upper case one instead:
defpytest_addoption(parser):
parser.addoption("-T", "--test", action="store")
The error message
AttributeError: 'Argument'object has no attribute 'dest'
is actually shown if you use an invalid abbreviation (with more than one letter), for example:
defpytest_addoption(parser):
parser.addoption("-tt", "--test", action="store")
The message is misleading - the actual error message is correct, but due to a glitch in the error handling in pytest the error is not propagated to the caller, and you get that message instead.
As to why you get this message - either your test was different from the one you have shown, or in your version of pytest the correct error (lowercase shortoptions reserved
) is also incorrectly propagated.
Post a Comment for "Python, Pytest Is It Possbile To Add Both Long And Short Args?"