def run_devpi(*args, **kwargs): callargs = [] for arg in ["devpi", "--clientdir", clientdir] + list(args): if isinstance(arg, URL): arg = arg.url callargs.append(str(arg)) print_info("*** inline$ %s" % " ".join(callargs)) hub, method = initmain(callargs) monkeypatch.setattr(hub, "ask_confirm", ask_confirm) expected = kwargs.get("code", None) try: method(hub, hub.args) except SystemExit as sysex: hub.sysex = sysex if expected == None or expected < 0 or expected >= 400: # we expected an error or nothing, don't raise pass else: raise finally: hub.close() if expected is not None: if expected == -2: # failed-to-start assert hasattr(hub, "sysex") elif isinstance(expected, list): assert hub._last_http_stati == expected else: if not isinstance(expected, tuple): expected = (expected, ) if hub._last_http_status not in expected: pytest.fail("got http code %r, expected %r" % (hub._last_http_status, expected)) return hub
def run_devpi(*args): tmpdir.chdir() callargs = ["devpi", "--clientdir", clientdir] + list(args) callargs = [str(x) for x in callargs] print_("*** inline$ %s" % " ".join(callargs)) hub, method = initmain(callargs) ret = method(hub, hub.args) if ret: raise SystemExit(ret) return hub
def run_devpi(*args, **kwargs): callargs = ["devpi", "--clientdir", clientdir] + list(args) callargs = [str(x) for x in callargs] print_info("*** inline$ %s" % " ".join(callargs)) hub, method = initmain(callargs) try: method(hub, hub.args) except SystemExit as sysex: hub.sysex = sysex expected = kwargs.get("code", None) if expected is not None: if not isinstance(expected, tuple): expected = (expected,) if hub._last_http_status not in expected: pytest.fail("got http code %r, expected %r" % (hub._last_http_status, expected)) return hub
def run_devpi(*args, **kwargs): callargs = ["devpi", "--clientdir", clientdir] + list(args) callargs = [str(x) for x in callargs] print_info("*** inline$ %s" % " ".join(callargs)) hub, method = initmain(callargs) try: method(hub, hub.args) except SystemExit as sysex: hub.sysex = sysex expected = kwargs.get("code", None) if expected is not None: if not isinstance(expected, tuple): expected = (expected, ) if hub._last_http_status not in expected: pytest.fail("got http code %r, expected %r" % (hub._last_http_status, expected)) return hub
def test_initmain(): with pytest.raises(SystemExit) as excinfo: initmain(["devpi"]) assert excinfo.value.args == (0, )
def uploadhub(request, tmpdir): from devpi.main import initmain hub, method = initmain(["devpitest", "--clientdir", tmpdir.join("client").strpath, "upload"]) return hub
def uploadhub(request, tmpdir): from devpi.main import initmain hub, method = initmain( ["devpitest", "--clientdir", tmpdir.join("client").strpath, "upload"]) return hub