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

Method test_drop_short_helper

testing/test_parseopt.py:200–235  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

198 assert option.no is False
199
200 def test_drop_short_helper(self) -> None:
201 parser = argparse.ArgumentParser(
202 formatter_class=parseopt.DropShorterLongHelpFormatter, allow_abbrev=False
203 )
204 parser.add_argument(
205 "-t", "--twoword", "--duo", "--two-word", "--two", help="foo"
206 )
207 # throws error on --deux only!
208 parser.add_argument(
209 "-d", "--deuxmots", "--deux-mots", action="store_true", help="foo"
210 )
211 parser.add_argument("-s", action="store_true", help="single short")
212 parser.add_argument("--abc", "-a", action="store_true", help="bar")
213 parser.add_argument("--klm", "-k", "--kl-m", action="store_true", help="bar")
214 parser.add_argument(
215 "-P", "--pq-r", "-p", "--pqr", action="store_true", help="bar"
216 )
217 parser.add_argument(
218 "--zwei-wort", "--zweiwort", "--zweiwort", action="store_true", help="bar"
219 )
220 parser.add_argument(
221 "-x", "--exit-on-first", "--exitfirst", action="store_true", help="spam"
222 )
223 parser.add_argument("files_and_dirs", nargs="*")
224 args = parser.parse_args(["-k", "--duo", "hallo", "--exitfirst"])
225 assert args.twoword == "hallo"
226 assert args.klm is True
227 assert args.zwei_wort is False
228 assert args.exit_on_first is True
229 assert args.s is False
230 args = parser.parse_args(["--deux-mots"])
231 with pytest.raises(AttributeError):
232 assert args.deux_mots is True
233 assert args.deuxmots is True
234 args = parser.parse_args(["file", "dir"])
235 assert "|".join(args.files_and_dirs) == "file|dir"
236
237 def test_drop_short_0(self, parser: parseopt.Parser) -> None:
238 parser.addoption("--funcarg", "--func-arg", action="store_true")

Callers

nothing calls this directly

Calls 1

parse_argsMethod · 0.80

Tested by

no test coverage detected