Closed ruffsl closed 2 years ago
For 57acdaaeeb67ddd8e8dadafd52b1d8498227f370 , I borrowed the test scaffolding from colcon-core, but I'm still not sure how it fixed the tests from erroring out from the expected ArgumentError. @cottsay , Do you know why this class based approach is needed.
Do you know why this class based approach is needed.
The default behavior when argparse
reacts to an ArgumentError
is to call exit
after printing the usage message. Unfortunately, this exits the tests as well. The _RaisingArgumentParser
overrides the exit behavior to re-throw the exception that triggered the exit so that it can be caught instead. As it happens, Python 3.9 introduced a new kwarg to ArgumentParser
to elicit this exact behavior, but we'll need to hang on to this implementation until we drop support for Python 3.8.
All that said, the class is designed to be instantiated in place of an argument parser and not as a test fixture, so I'm not sure how it's working in this code.
I'm not sure how it's working in this code
I see - It's actually not working right now. test_suppress_argument_error
isn't getting executed because the class name doesn't contain Test
, I believe.
Base: 100.00% // Head: 100.00% // No change to project coverage :thumbsup:
Coverage data is based on head (
dca1862
) compared to base (ad2d111
). Patch coverage: 100.00% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Ah, ok. I fixed and simplified the monkey patching to override the stock error method.
Fix help message when printing default for --base-select To ensure all available base select options are displayed, including any external base handler extensions.
And add --base-ignore to ignore (default) base paths otherwise selected.
This allows uses to do things like cleaning all but a few ignored base paths, regardless of how many other base path and extension may be present.