Apart from adding this feature there are a few changes to the tests. I couldn't just implement the feature without solving them first.
I found silent failures in the tests as the result of the "catch all" block with the print in the main function. These issue were solved (not very elegantly, but with less mocking) in the first commit in this PR. Here are the problems I found:
In test_main_first_arg_help, mocking argparse cause it not to raise SystemExit as it usually does when called with --help. So, the code continues and fails in extract. This failure is ignored. In addition, the test didn't checked anything related to the functionallity of the --help flag.
In test_main_first_arg_version, argparse failed as it type checks the arguments and '%(prog)s ' + get_version() is a mock instead of an expected string. The failure (TypeError), again, was ignored. And again, the test checked almost nothing relevant.
I think that the rest of this PR is strightforward. Please ask if more elaboration needed.
Apart from adding this feature there are a few changes to the tests. I couldn't just implement the feature without solving them first. I found silent failures in the tests as the result of the "catch all" block with the
print
in themain
function. These issue were solved (not very elegantly, but with less mocking) in the first commit in this PR. Here are the problems I found:In
test_main_first_arg_help
, mocking argparse cause it not to raiseSystemExit
as it usually does when called with--help
. So, the code continues and fails inextract
. This failure is ignored. In addition, the test didn't checked anything related to the functionallity of the--help
flag.In
test_main_first_arg_version
, argparse failed as it type checks the arguments and'%(prog)s ' + get_version()
is a mock instead of an expected string. The failure (TypeError
), again, was ignored. And again, the test checked almost nothing relevant.I think that the rest of this PR is strightforward. Please ask if more elaboration needed.