Exemplo n.º 1
0
def test_subprocess_no_env_ok_if_not_exists():
    if TEMP_NAME in os.environ:
        del os.environ[TEMP_NAME]
    with util.no_env(TEMP_NAME):
        out, _ = util.launch("env")
        for o in out.split("\n"):
            if o.startswith(TEMP_NAME):
                assert False, "%s found in os.environ" % TEMP_NAME

    assert TEMP_NAME not in os.environ
Exemplo n.º 2
0
def test_subprocess_set_env_ok_if_not_exists():
    if TEMP_NAME in os.environ:
        del os.environ[TEMP_NAME]
    with util.set_env(TEMP_NAME, "anything"):
        out, _ = util.launch("env")
        for o in out.split("\n"):
            if o.startswith(TEMP_NAME):
                assert o == "%s=anything" % TEMP_NAME
                break
        else:
            assert False, "%s not found in os.environ" % TEMP_NAME
Exemplo n.º 3
0
def test_subprocess_no_env_ok_if_exists():
    ev = os.environ[TEMP_NAME] = "junk_name"
    try:
        with util.no_env(TEMP_NAME):
            out, _ = util.launch("env")
            for o in out.split("\n"):
                if o.startswith(TEMP_NAME):
                    assert False, "%s found in os.environ" % TEMP_NAME

        assert os.environ[TEMP_NAME] == ev
    finally:
        del os.environ[TEMP_NAME]
Exemplo n.º 4
0
def test_subprocess_set_env_ok_if_exists():
    ev = os.environ[TEMP_NAME] = "junk_name"
    try:
        with util.set_env(TEMP_NAME, "anything"):
            out, _ = util.launch("env")
            for o in out.split("\n"):
                if o.startswith(TEMP_NAME):
                    assert o == "%s=anything" % TEMP_NAME
                    break
            else:
                assert False, "%s not found in os.environ" % TEMP_NAME
        assert os.environ[TEMP_NAME] == ev

    finally:
        del os.environ[TEMP_NAME]
Exemplo n.º 5
0
def test_launch():
    out, _ = util.launch(["env"])
    assert "HOME=" in out