예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
 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
예제 #4
0
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
예제 #5
0
 def test_addsubparser(self):
     parser = MyArgumentParser()
     sub = parser.add_subparsers()
     p = sub.add_parser("hello")
     assert isinstance(p, MyArgumentParser)
예제 #6
0
 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
예제 #7
0
 def test_addoption(self):
     parser = MyArgumentParser()
     parser.addoption("--hello", type=str)
     args = parser.parse_args(["--hello", "world"])
     assert args.hello == "world"
예제 #8
0
 def test_addoption(self):
     parser = MyArgumentParser()
     parser.addoption("--hello", type=str)
     args = parser.parse_args(["--hello", "world"])
     assert args.hello == "world"
예제 #9
0
 def test_addsubparser(self):
     parser = MyArgumentParser()
     sub = parser.add_subparsers()
     p = sub.add_parser("hello")
     assert isinstance(p, MyArgumentParser)
예제 #10
0
 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
예제 #11
0
 def test_addoption_getdefault(self):
     parser = MyArgumentParser()
     opt = parser.addoption("--hello1", type=str, help="x", default="world1")
     assert "[world1]" in opt.help
예제 #12
0
 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