def test_get_output_already_sourced(tmpdir, venv_path, active_env): make_venv_in_tempdir(tmpdir) output = aactivator.get_output( dict(active_env), str(venv_path), lambda: 'y', ) assert output == ''
def test_get_output_pwd_goes_missing(tmpdir, venv_path, inactive_env): make_venv_in_tempdir(tmpdir) with venv_path.as_cwd(): venv_path.remove(rec=1) output = aactivator.get_output( dict(inactive_env), str(venv_path), lambda: 'n', ) assert output == ''
def test_get_output_sourced_deeper_in_directory(tmpdir, venv_path, active_env): make_venv_in_tempdir(tmpdir) deeper = venv_path.mkdir('deeper') output = aactivator.get_output( dict(active_env), str(deeper), lambda: 'y', ) assert output == ''
def test_not_sourced_sources(tmpdir, venv_path, inactive_env): make_venv_in_tempdir(tmpdir) output = aactivator.get_output( dict(inactive_env), str(venv_path), lambda: 'y', ) assert (output == '''\ aactivator security-check .activate.sh && source ./.activate.sh && export AACTIVATOR_ACTIVE=''' + str(venv_path))
def test_get_output_sourced_not_in_directory(tmpdir, venv_path, active_env): make_venv_in_tempdir(tmpdir) output = aactivator.get_output( dict(active_env), str(tmpdir), ) assert (output == '''\ OLDPWD_bak="$OLDPWD" && cd {venv_path} && aactivator security-check .deactivate.sh && source ./.deactivate.sh unset AACTIVATOR_ACTIVE && cd "$OLDPWD_bak" && cd {tmpdir} && unset OLDPWD_bak'''.format(venv_path=str(venv_path), tmpdir=str(tmpdir)))
def test_get_output_change_venv(tmpdir, venv_path, active_env): make_venv_in_tempdir(tmpdir) venv2 = make_venv_in_tempdir(tmpdir, 'venv2') output = aactivator.get_output( dict(active_env), str(venv2), lambda: 'y', ) assert (output == '''\ OLDPWD_bak="$OLDPWD" && cd {venv_path} && aactivator security-check .deactivate.sh && source ./.deactivate.sh unset AACTIVATOR_ACTIVE && cd "$OLDPWD_bak" && cd {venv_path}2 && unset OLDPWD_bak && aactivator security-check .activate.sh && source ./.activate.sh && export AACTIVATOR_ACTIVE={venv_path}2'''.format(venv_path=str(venv_path)))
def test_get_output_nothing_special(tmpdir, inactive_env): output = aactivator.get_output( dict(inactive_env), str(tmpdir), ) assert output == ''