MCPcopy Create free account
hub / github.com/pytest-dev/pytest / pytest_cmdline_parse

Method pytest_cmdline_parse

src/_pytest/config/__init__.py:1009–1033  ·  view source on GitHub ↗
(
        self, pluginmanager: PytestPluginManager, args: List[str]
    )

Source from the content-addressed store, hash-verified

1007 return terminalreporter._tw
1008
1009 def pytest_cmdline_parse(
1010 self, pluginmanager: PytestPluginManager, args: List[str]
1011 ) -> "Config":
1012 try:
1013 self.parse(args)
1014 except UsageError:
1015
1016 # Handle --version and --help here in a minimal fashion.
1017 # This gets done via helpconfig normally, but its
1018 # pytest_cmdline_main is not called in case of errors.
1019 if getattr(self.option, "version", False) or "--version" in args:
1020 from _pytest.helpconfig import showversion
1021
1022 showversion(self)
1023 elif (
1024 getattr(self.option, "help", False) or "--help" in args or "-h" in args
1025 ):
1026 self._parser._getparser().print_help()
1027 sys.stdout.write(
1028 "\nNOTE: displaying only minimal help due to UsageError.\n\n"
1029 )
1030
1031 raise
1032
1033 return self
1034
1035 def notify_exception(
1036 self,

Callers 1

_prepareconfigFunction · 0.80

Calls 4

parseMethod · 0.95
showversionFunction · 0.90
_getparserMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected