def test_addgroup(self): parser = MyArgumentParser() group = parser.addgroup("hello") opt = group.addoption("--hello", default="world", type=str, help="x") parser.post_process_actions() assert opt.default == "world" assert "[world]" in opt.help
def test_addoption_getdefault(self): def getter(name): return dict(hello="world2")[name] parser = MyArgumentParser(defaultget=getter) opt = parser.addoption("--hello", default="world", type=str, help="x") assert opt.default == "world2" assert "[world2]" in opt.help opt = parser.addoption("--hello2", default="world", type=str, help="x") assert opt.default == "world" assert "[world]" in opt.help
def clear_index(argv=None): if argv is None: argv = sys.argv else: # for tests argv = [str(x) for x in argv] pluginmanager = get_pluginmanager() try: parser = MyArgumentParser(description="Clear project search index.", add_help=False) add_help_option(parser, pluginmanager) add_configfile_option(parser, pluginmanager) add_storage_options(parser, pluginmanager) add_indexer_backend_option(parser, pluginmanager) config = parseoptions(pluginmanager, argv, parser=parser) configure_cli_logging(config.args) xom = xom_from_config(config) log = xom.log log.warn("You should stop devpi-server before running this command.") ix = get_indexer(xom) ix.delete_index() log.info( "Index deleted, start devpi-server again to let the index rebuild automatically." ) except Fatal as e: tw = py.io.TerminalWriter(sys.stderr) tw.line("fatal: %s" % e.args[0], red=True) return 1
def test_addsubparser(self): parser = MyArgumentParser() sub = parser.add_subparsers() p = sub.add_parser("hello") assert isinstance(p, MyArgumentParser)
def test_addoption_default_added_to_help(self): parser = MyArgumentParser() opt = parser.addoption("--hello", type=str, help="x", default="world") parser.post_process_actions() assert "[world]" in opt.help
def test_addoption(self): parser = MyArgumentParser() parser.addoption("--hello", type=str) args = parser.parse_args(["--hello", "world"]) assert args.hello == "world"
def test_addgroup(self): parser = MyArgumentParser() group = parser.addgroup("hello") opt = group.addoption("--hello", default="world", type=str, help="x") assert opt.default == "world" assert "[world]" in opt.help
def test_addoption_getdefault(self): parser = MyArgumentParser() opt = parser.addoption("--hello1", type=str, help="x", default="world1") assert "[world1]" in opt.help
def test_addoption_default_added_to_help(self): parser = MyArgumentParser() opt = parser.addoption("--hello", type=str, help="x", default="world") assert "[world]" in opt.help