Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
argparse exits with code 2 on (usage) errors, should be mapped to UsageError #2753
With pytest-watch I've noticed that
This could be mapped into throwing
diff --git i/_pytest/config.py w/_pytest/config.py index 364ac13c..0e879f34 100644 --- i/_pytest/config.py +++ w/_pytest/config.py @@ -801,6 +801,9 @@ def parse_args(self, args=None, namespace=None): getattr(args, FILE_OR_DIR).extend(argv) return args + def error(self, message): + raise UsageError(self.format_usage(), message) + class DropShorterLongHelpFormatter(argparse.HelpFormatter): """shorten help for long options that differ only in extra hyphens
But at least it sounds sensible to wrap it and exit with pytest's "usage error" code, which would be 4 according to https://docs.pytest.org/en/latest/_modules/_pytest/main.html.