returning error messages about custom options? #8609
Answered
by
The-Compiler
rvandegrift
asked this question in
Q&A
-
Hello, My def wooo(value):
if value != 'wooo':
raise ValueError(f'{value} is not equal to wooo')
def pytest_addoption(parser):
parser.addoption('--wooo', action='store', required=True, type=wooo) When I provide bad input, pytest swallows my error message and replaces it with a generic one: $ python3 -m pytest --wooo=asdf
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: argument --wooo: invalid wooo value: 'asdf' Is there any way to get my validation's error returned to the user? |
Beta Was this translation helpful? Give feedback.
Answered by
The-Compiler
Apr 29, 2021
Replies: 1 comment 1 reply
-
That's a feature of the underlying argparse module. You could raise a
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rvandegrift
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's a feature of the underlying argparse module.
You could raise a
pytest.UsageError
instead, which will instead display: