def _non_success_exit_code(capsys, target): with pytest.raises(SystemExit) as context: run_with_catch(args=[target]) assert context.value.code != 0 out, err = capsys.readouterr() assert not out, out return err
def test_fail_with_traceback(raise_on_session_done, tmp_path, capsys): raise_on_session_done(TypeError("something bad")) with pytest.raises(TypeError, match="something bad"): run_with_catch([str(tmp_path), "--with-traceback"]) out, err = capsys.readouterr() assert out == "" assert err == ""
def test_fail_no_traceback(raise_on_session_done, tmp_path, capsys): raise_on_session_done(ProcessCallFailed(code=2, out="out\n", err="err\n", cmd=["something"])) with pytest.raises(SystemExit) as context: run_with_catch([str(tmp_path)]) assert context.value.code == 2 out, err = capsys.readouterr() assert out == "subprocess call failed for [{}] with code 2\nout\nSystemExit: 2\n".format(repr("something")) assert err == "err\n"
def test_session_report_minimal(session_app_data, tmp_path, capsys): run_with_catch([str(tmp_path), "--activators", "", "--without-pip"]) out, err = capsys.readouterr() assert err == "" lines = out.splitlines() regexes = [ r"created virtual environment .* in \d+ms", r" creator .*", ] _match_regexes(lines, regexes)
def test_session_report_full(session_app_data, tmp_path, capsys): run_with_catch([str(tmp_path)]) out, err = capsys.readouterr() assert err == "" lines = out.splitlines() regexes = [ r"created virtual environment .* in \d+ms", r" creator .*", r" seeder .*", r" added seed packages: .*pip==.*, setuptools==.*, wheel==.*", r" activators .*", ] _match_regexes(lines, regexes)