From d044e9f642edd5bea5bac16c1952cb365e6ded34 Mon Sep 17 00:00:00 2001 From: markshao Date: Sat, 24 Dec 2022 11:28:55 +0800 Subject: [PATCH] fix the error when mix-use the cache-show and help option --- src/_pytest/config/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 25f156f8b..b997e47d9 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1074,6 +1074,12 @@ class Config: ) raise + except PrintHelp: + self._parser._getparser().print_help() + sys.stdout.write( + "\nNOTE: displaying only minimal help due to UsageError.\n\n" + ) + raise UsageError return self @@ -1368,7 +1374,7 @@ class Config: self.args = args self.args_source = source except PrintHelp: - pass + raise def issue_config_time_warning(self, warning: Warning, stacklevel: int) -> None: """Issue and handle a warning during the "configure" stage.