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

Method _getparser

src/_pytest/config/argparsing.py:116–133  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

114 return self.optparser.parse_args(strargs, namespace=namespace)
115
116 def _getparser(self) -> "MyOptionParser":
117 from _pytest._argcomplete import filescompleter
118
119 optparser = MyOptionParser(self, self.extra_info, prog=self.prog)
120 groups = self._groups + [self._anonymous]
121 for group in groups:
122 if group.options:
123 desc = group.description or group.name
124 arggroup = optparser.add_argument_group(desc)
125 for option in group.options:
126 n = option.names()
127 a = option.attrs()
128 arggroup.add_argument(*n, **a)
129 file_or_dir_arg = optparser.add_argument(FILE_OR_DIR, nargs="*")
130 # bash like autocompletion for dirs (appending '/')
131 # Type ignored because typeshed doesn't know about argcomplete.
132 file_or_dir_arg.completer = filescompleter # type: ignore
133 return optparser
134
135 def parse_setoption(
136 self,

Callers 4

parseMethod · 0.95
pytest_cmdline_parseMethod · 0.80
test_custom_progMethod · 0.80

Calls 3

MyOptionParserClass · 0.85
namesMethod · 0.80
attrsMethod · 0.80

Tested by 1

test_custom_progMethod · 0.64