Exemple #1
0
 def mkhub(arglist):
     arglist = [str(x) for x in arglist]
     tmp = handler.mktemp("hub")
     for x in arglist:
         if "--clientdir" in x:
             break
     else:
         arglist.append("--clientdir=%s" % tmp)
     args = parse_args(["devpi_"] + arglist)
     with tmp.as_cwd():
         return Hub(args)
Exemple #2
0
 def mkhub(arglist):
     arglist = [str(x) for x in arglist]
     tmp = handler.mktemp("hub")
     for x in arglist:
         if "--clientdir" in x:
             break
     else:
         arglist.append("--clientdir=%s" % tmp)
     args = parse_args(["devpi_"] + arglist)
     with tmp.as_cwd():
         return Hub(args)
Exemple #3
0
 def mkhub(arglist):
     arglist = [str(x) for x in arglist]
     tmp = tmpdir_factory.mktemp("hub")
     for x in arglist:
         if "--clientdir" in x:
             break
     else:
         arglist.append("--clientdir=%s" % tmp)
     pm = get_pluginmanager()
     args = parse_args(["devpi_"] + arglist, pm)
     with tmp.as_cwd():
         return Hub(args)
Exemple #4
0
def test_subcommands_hook(capsys):
    from devpi.main import get_pluginmanager, parse_args
    from pluggy import HookimplMarker

    calls = []

    class Plugin:
        @HookimplMarker("devpiclient")
        def devpiclient_subcommands(self):
            def myplugincmd_arguments(parser):
                """ myplugindescription """
                calls.append(('myplugincmd_arguments', ))

            return [(myplugincmd_arguments, 'myplugincmd', 'mypluginlocation')]

    pm = get_pluginmanager()
    with pytest.raises(SystemExit) as e:
        parse_args(['devpi', '-h'], pm)
    assert e.value.args == (0, )
    (out, err) = capsys.readouterr()
    assert 'patchjson' in out
    assert 'myplugincmd' not in out
    assert 'myplugindescription' not in out
    assert calls == []
    pm.register(Plugin())
    with pytest.raises(SystemExit) as e:
        parse_args(['devpi', '-h'], pm)
    assert e.value.args == (0, )
    (out, err) = capsys.readouterr()
    assert 'patchjson' in out
    assert 'myplugincmd' in out
    assert 'myplugindescription' in out
    assert calls == [('myplugincmd_arguments', )]
    args = parse_args(['devpi', 'myplugincmd'], pm)
    assert args.command == 'myplugincmd'
    assert args.mainloc == 'mypluginlocation'