Ejemplo n.º 1
0
def in_env(repo_cmd_runner, language_version):
    envdir = os.path.join(
        repo_cmd_runner.prefix_dir,
        helpers.environment_dir(ENVIRONMENT_DIR, language_version),
    )
    with envcontext(get_env_patch(envdir)):
        yield
Ejemplo n.º 2
0
def test_exception_safety():
    class MyError(RuntimeError):
        pass

    env = {}
    with pytest.raises(MyError):
        with envcontext([('foo', 'bar')], _env=env):
            raise MyError()
    assert env == {}
Ejemplo n.º 3
0
def _test(**kwargs):
    before = kwargs.pop('before')
    patch = kwargs.pop('patch')
    expected = kwargs.pop('expected')
    assert not kwargs

    env = before.copy()
    with envcontext(patch, _env=env):
        assert env == expected
    assert env == before
Ejemplo n.º 4
0
def in_env(repo_cmd_runner, language_version):  # pragma: windows no cover
    envdir = repo_cmd_runner.path(
        helpers.environment_dir(ENVIRONMENT_DIR, language_version),
    )
    with envcontext(get_env_patch(envdir)):
        yield
Ejemplo n.º 5
0
def in_env(prefix):  # pragma: windows no cover
    envdir = prefix.path(
        helpers.environment_dir(ENVIRONMENT_DIR, C.DEFAULT),
    )
    with envcontext(get_env_patch(envdir)):
        yield
Ejemplo n.º 6
0
def bin_on_path():
    bindir = os.path.join(os.getcwd(), 'bin')
    with envcontext((('PATH', (bindir, os.pathsep, Var('PATH'))),)):
        yield
Ejemplo n.º 7
0
def in_env(repo_cmd_runner):
    envdir = repo_cmd_runner.path(
        helpers.environment_dir(ENVIRONMENT_DIR, 'default'),
    )
    with envcontext(get_env_patch(envdir)):
        yield
Ejemplo n.º 8
0
def in_env(repo_cmd_runner):  # pragma: windows no cover
    envdir = repo_cmd_runner.path(helpers.environment_dir(ENVIRONMENT_DIR, "default"))
    with envcontext(get_env_patch(envdir)):
        yield
Ejemplo n.º 9
0
def in_env(prefix):
    target_dir = prefix.path(
        helpers.environment_dir(ENVIRONMENT_DIR, C.DEFAULT),
    )
    with envcontext(get_env_patch(target_dir)):
        yield
Ejemplo n.º 10
0
def in_env(prefix, language_version):  # pragma: windows no cover
    envdir = prefix.path(
        helpers.environment_dir(ENVIRONMENT_DIR, language_version),
    )
    with envcontext(get_env_patch(envdir, language_version)):
        yield
Ejemplo n.º 11
0
def test_integration_os_environ():
    with mock.patch.dict(os.environ, {'FOO': 'bar'}, clear=True):
        assert os.environ == {'FOO': 'bar'}
        with envcontext([('HERP', 'derp')]):
            assert os.environ == {'FOO': 'bar', 'HERP': 'derp'}
        assert os.environ == {'FOO': 'bar'}
Ejemplo n.º 12
0
 def in_env(prefix, language_version):
     envdir = prefix.path(helpers.environment_dir(_dir, language_version))
     with envcontext(get_env_patch(envdir)):
         yield
Ejemplo n.º 13
0
def in_env(prefix, language_version):  # pragma: windows no cover
    with envcontext(get_env_patch(_envdir(prefix, language_version))):
        yield