def test_activate_root(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix="envs", dir=dirname(__file__)) as envs: commands = ( shell_vars["command_setup"] + """ {source} "{syspath}{binpath}activate" root {printpath} """ ).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_in(shells[shell]["pathsep"].join(_envpaths(root_dir, shelldict=shells[shell])), stdout, stderr) commands = ( shell_vars["command_setup"] + """ {source} "{syspath}{binpath}activate" root {source} "{syspath}{binpath}deactivate" {printpath} """ ).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) stdout = strip_leading_library_bin(stdout, shells[shell]) assert_equals(stdout, u"%s" % shell_vars["base_path"], stderr)
def test_activate_symlinking(shell): """Symlinks or bat file redirects are created at activation time. Make sure that the files/links exist, and that they point where they should.""" shell_vars = _format_vars(shell) with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{cmd_path}activate" "{env_dirs[0]}" """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stderr, u'prepending {envpaths1} to PATH'\ .format(syspath=pathlist_to_str(_envpaths(root_dir)), envpaths1=pathlist_to_str(_envpaths(envs, 'test1')))) where = 'Scripts' if sys.platform == 'win32' else 'bin' for env in gen_test_env_paths(envs, shell)[:2]: scripts = { where: ["conda"], 'cmd': ["activate", "deactivate"], } for where, files in scripts.items(): for f in files: if sys.platform == "win32": file_path = shells[shell]["slash_convert"][1].join( [env, where, f + shells[shell]["shell_suffix"]]) # must translate path to windows representation for Python's sake file_path = shells[shell]["path_from"](file_path) assert (os.path.lexists(file_path)) else: file_path = join(env, where, f) assert (os.path.lexists(file_path)) s = os.lstat(file_path) assert (stat.S_ISLNK(s.st_mode)) assert (os.readlink(file_path) == '{root_path}'.format( root_path=join(sys.prefix, where, f))) if platform != 'win': # Test activate when there are no write permissions in the # env. prefix_bin_path = join(gen_test_env_paths(envs, shell)[2], 'bin') commands = (shell_vars['command_setup'] + """ mkdir -p {prefix_bin_path} chmod 000 {prefix_bin_path} {source} activate "{env_dirs[2]}" """).format(prefix_bin_path=prefix_bin_path, envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_in("do not have write access", stderr) # restore permissions so the dir will get cleaned up run_in( "chmod 777 {prefix_bin_path}".format( prefix_bin_path=prefix_bin_path), shell)
def test_activate_bad_env_keeps_existing_good_env(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} {syspath}{binpath}activate "{env_dirs[0]}" {nul} {source} "{syspath}{binpath}activate" "{env_dirs[2]}" {printpath} """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_in(shells[shell]['pathsep'].join(_envpaths(envs, 'test 1', shelldict=shells[shell])),stdout)
def test_activate_test1(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate{shell_suffix}" "{env_dirs[0]}" {printpath} """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_in(shells[shell]['pathsep'].join(_envpaths(envs, 'test 1', shell)), stdout, shell)
def test_wrong_args(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate" two args {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) stdout = strip_leading_library_bin(stdout, shells[shell]) assert_in("activate does not accept more than one argument", stderr) assert_equals(stdout, shell_vars['base_path'], stderr)
def test_activate_test1(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{cmd_path}activate{shell_suffix}" "{env_dirs[0]}" {printpath} """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stderr, u'prepending {envpaths} to PATH'\ .format(envpaths=pathlist_to_str(_envpaths(envs, 'test1'), False)), shell) assert_in(pathsep.join(_envpaths(envs, 'test1')), shells[shell]["path_from"](stdout), shell)
def test_activate_test1(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix="envs", dir=dirname(__file__)) as envs: commands = ( shell_vars["command_setup"] + """ {source} "{syspath}{binpath}activate{shell_suffix}" "{env_dirs[0]}" {printpath} """ ).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_in(shells[shell]["pathsep"].join(_envpaths(envs, "test 1", shelldict=shells[shell])), stdout, shell)
def test_activate_bad_env_keeps_existing_good_env(shell): if shell == 'bash.exe': pytest.skip("usage of cygpath in win_path_to_unix messes this test up") shell_vars = _format_vars(shell) with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} {syspath}{binpath}activate "{env_dirs[0]}" {nul} {source} "{syspath}{binpath}activate" "{env_dirs[3]}" {printpath} """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_in(shells[shell]['pathsep'].join(_envpaths(envs, 'test 1', shell)), stdout)
def test_activate_env_from_env_with_root_activate(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate" "{env_dirs[0]}" {nul} {source} "{syspath}{binpath}activate" "{env_dirs[1]}" {printpath} """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stderr, u'prepending {envpaths2} to PATH'\ .format(envpaths2=pathlist_to_str(_envpaths(envs, 'test 2', shelldict=shells[shell])))) assert_in(shells[shell]['pathsep'].join(_envpaths(envs, 'test 2', shelldict=shells[shell])), stdout)
def test_activate_help(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix="envs", dir=dirname(__file__)) as envs: if shell not in ["powershell.exe", "cmd.exe"]: commands = ( shell_vars["command_setup"] + """ "{syspath}{binpath}activate" Zanzibar """ ).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, "") assert_in("activate must be sourced", stderr) # assert_in("Usage: source activate ENV", stderr) commands = ( shell_vars["command_setup"] + """ {source} "{syspath}{binpath}activate" --help """ ).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, "") if shell in ["cmd.exe", "powershell"]: # assert_in("Usage: activate ENV", stderr) pass else: # assert_in("Usage: source activate ENV", stderr) commands = ( shell_vars["command_setup"] + """ {syspath}{binpath}deactivate """ ).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, "") assert_in("deactivate must be sourced", stderr) # assert_in("Usage: source deactivate", stderr) commands = ( shell_vars["command_setup"] + """ {source} {syspath}{binpath}deactivate --help """ ).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, "")
def test_activate_root_env_from_other_env(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{cmd_path}activate" "{env_dirs[0]}" {nul} {source} "{syspath}{cmd_path}activate" root {printpath} """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_in(shells[shell]["path_to"](pathsep.join(_envpaths(root_dir))), stdout) assert_not_in(shells[shell]["path_to"](pathsep.join(_envpaths(envs, 'test1'))), stdout)
def test_wrong_args(shell): if shell == 'bash.exe': pytest.skip("usage of cygpath in win_path_to_unix messes this test up") shell_vars = _format_vars(shell) with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate" two args {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) stdout = strip_leading_library_bin(stdout, shells[shell]) assert_in("activate does not accept more than one argument", stderr) assert_equals(stdout, shell_vars['base_path'], stderr)
def test_activate_symlinking(shell): """Symlinks or bat file redirects are created at activation time. Make sure that the files/links exist, and that they point where they should.""" shell_vars = _format_vars(shell) with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{cmd_path}activate" "{env_dirs[0]}" """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stderr, u'prepending {envpaths1} to PATH'\ .format(syspath=pathlist_to_str(_envpaths(root_dir)), envpaths1=pathlist_to_str(_envpaths(envs, 'test1')))) where = 'Scripts' if sys.platform == 'win32' else 'bin' for env in gen_test_env_paths(envs, shell)[:2]: scripts = {where: ["conda"], 'cmd': ["activate", "deactivate"], } for where, files in scripts.items(): for f in files: if sys.platform == "win32": file_path = shells[shell]["slash_convert"][1].join([env, where, f + shells[shell]["shell_suffix"]]) # must translate path to windows representation for Python's sake file_path = shells[shell]["path_from"](file_path) assert(os.path.lexists(file_path)) else: file_path = join(env, where, f) assert(os.path.lexists(file_path)) s = os.lstat(file_path) assert(stat.S_ISLNK(s.st_mode)) assert(os.readlink(file_path) == '{root_path}'.format(root_path=join(sys.prefix, where, f))) if platform != 'win': # Test activate when there are no write permissions in the # env. prefix_bin_path = join(gen_test_env_paths(envs, shell)[2], 'bin') commands = (shell_vars['command_setup'] + """ mkdir -p {prefix_bin_path} chmod 000 {prefix_bin_path} {source} activate "{env_dirs[2]}" """).format(prefix_bin_path=prefix_bin_path, envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_in("do not have write access", stderr) # restore permissions so the dir will get cleaned up run_in("chmod 777 {prefix_bin_path}".format(prefix_bin_path=prefix_bin_path), shell)
def test_activate_root_env_from_other_env(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{cmd_path}activate" "{env_dirs[0]}" {nul} {source} "{syspath}{cmd_path}activate" root {printpath} """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_in(shells[shell]["path_to"](pathsep.join(_envpaths(root_dir))), stdout) assert_not_in( shells[shell]["path_to"](pathsep.join(_envpaths(envs, 'test1'))), stdout)
def test_activate_bad_env_keeps_existing_good_env(shell): if shell == 'bash.exe': pytest.skip("usage of cygpath in win_path_to_unix messes this test up") shell_vars = _format_vars(shell) with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} {syspath}{binpath}activate "{env_dirs[0]}" {nul} {source} "{syspath}{binpath}activate" "{env_dirs[3]}" {printpath} """).format(envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_in( shells[shell]['pathsep'].join(_envpaths(envs, 'test 1', shell)), stdout)
def test_activate_symlinking(shell): """Symlinks or bat file redirects are created at activation time. Make sure that the files/links exist, and that they point where they should.""" shell_vars = _format_vars(shell) with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs: where = 'Scripts' if on_win else 'bin' for env in gen_test_env_paths(envs, shell)[:2]: scripts = ["conda", "activate", "deactivate"] for f in scripts: if on_win: file_path = os.path.join(env, where, f + shells[shell]["shell_suffix"]) # must translate path to windows representation for Python's sake file_path = shells[shell]["path_from"](file_path) assert (os.path.lexists(file_path)) else: file_path = os.path.join(env, where, f) assert (os.path.lexists(file_path)) s = os.lstat(file_path) assert (stat.S_ISLNK(s.st_mode)) assert (os.readlink(file_path) == '{root_path}'.format( root_path=os.path.join(sys.prefix, where, f))) if platform != 'win': # Test activate when there are no write permissions in the # env. prefix_bin_path = os.path.join( gen_test_env_paths(envs, shell)[2], 'bin') commands = (shell_vars['command_setup'] + """ mkdir -p "{prefix_bin_path}" chmod 444 "{prefix_bin_path}" {source} activate "{env_dirs[2]}" """).format(prefix_bin_path=prefix_bin_path, envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_in("not have write access", stderr) # restore permissions so the dir will get cleaned up run_in( 'chmod 777 "{prefix_bin_path}"'.format( prefix_bin_path=prefix_bin_path), shell)
def test_activate_root(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{cmd_path}activate" root {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_in(shells[shell]["path_to"](pathsep.join(_envpaths(root_dir))), stdout) commands = (shell_vars['command_setup'] + """ {source} "{syspath}{cmd_path}activate" root {source} "{syspath}{cmd_path}deactivate" {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, u"%s" % shell_vars['base_path'], stderr)
def test_activate_root(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate" root {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_in(shells[shell]['pathsep'].join(_envpaths(root_dir, shelldict=shells[shell])), stdout, stderr) commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate" root {source} "{syspath}{binpath}deactivate" {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) stdout = strip_leading_library_bin(stdout, shells[shell]) assert_equals(stdout, u"%s" % shell_vars['base_path'], stderr)
def test_activate_root_simple(shell): if shell == 'bash.exe': pytest.skip("usage of cygpath in win_path_to_unix messes this test up") shell_vars = _format_vars(shell) with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate" root {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_in( shells[shell]['pathsep'].join( _envpaths(context.root_prefix, shell=shell)), stdout, stderr) assert not stderr # debug TODO: remove if shell == 'bash.exe': commands = (shell_vars['command_setup'] + """ env | sort {source} "{syspath}{binpath}activate" root env | sort echo {source} "{syspath}{binpath}deactivate" {source} "{syspath}{binpath}deactivate" env | sort {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) sys.stdout.write(stdout) sys.stderr.write(stderr) commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate" root {source} "{syspath}{binpath}deactivate" {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert not stderr stdout = strip_leading_library_bin(stdout, shells[shell]) assert_equals(stdout, u'%s' % shell_vars['base_path'])
def test_activate_root_simple(shell): if shell == 'bash.exe': pytest.skip("usage of cygpath in win_path_to_unix messes this test up") shell_vars = _format_vars(shell) with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate" root {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_in(shells[shell]['pathsep'].join(_envpaths(context.root_prefix, shell=shell)), stdout, stderr) assert not stderr # debug TODO: remove if shell == 'bash.exe': commands = (shell_vars['command_setup'] + """ env | sort {source} "{syspath}{binpath}activate" root env | sort echo {source} "{syspath}{binpath}deactivate" {source} "{syspath}{binpath}deactivate" env | sort {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) sys.stdout.write(stdout) sys.stderr.write(stderr) commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate" root {source} "{syspath}{binpath}deactivate" {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert not stderr stdout = strip_leading_library_bin(stdout, shells[shell]) assert_equals(stdout, u'%s' % shell_vars['base_path'])
def test_activate_help(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs: if shell not in ['powershell.exe', 'cmd.exe']: commands = (shell_vars['command_setup'] + """ "{syspath}{binpath}activate" Zanzibar """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, '') assert_in("activate must be sourced", stderr) # assert_in("Usage: source activate ENV", stderr) commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate" --help """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, '') if shell in ["cmd.exe", "powershell"]: # assert_in("Usage: activate ENV", stderr) pass else: # assert_in("Usage: source activate ENV", stderr) commands = (shell_vars['command_setup'] + """ {syspath}{binpath}deactivate """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, '') assert_in("deactivate must be sourced", stderr) # assert_in("Usage: source deactivate", stderr) commands = (shell_vars['command_setup'] + """ {source} {syspath}{binpath}deactivate --help """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, '')
def test_activate_symlinking(shell): """Symlinks or bat file redirects are created at activation time. Make sure that the files/links exist, and that they point where they should.""" shell_vars = _format_vars(shell) with TemporaryDirectory(prefix="envs", dir=dirname(__file__)) as envs: where = "Scripts" if on_win else "bin" for env in gen_test_env_paths(envs, shell)[:2]: scripts = ["conda", "activate", "deactivate"] for f in scripts: if on_win: file_path = os.path.join(env, where, f + shells[shell]["shell_suffix"]) # must translate path to windows representation for Python's sake file_path = shells[shell]["path_from"](file_path) assert os.path.lexists(file_path) else: file_path = os.path.join(env, where, f) assert os.path.lexists(file_path) s = os.lstat(file_path) assert stat.S_ISLNK(s.st_mode) assert os.readlink(file_path) == "{root_path}".format(root_path=os.path.join(sys.prefix, where, f)) if platform != "win": # Test activate when there are no write permissions in the # env. prefix_bin_path = os.path.join(gen_test_env_paths(envs, shell)[2], "bin") commands = ( shell_vars["command_setup"] + """ mkdir -p "{prefix_bin_path}" chmod 444 "{prefix_bin_path}" {source} activate "{env_dirs[2]}" """ ).format(prefix_bin_path=prefix_bin_path, envs=envs, env_dirs=gen_test_env_paths(envs, shell), **shell_vars) stdout, stderr = run_in(commands, shell) assert_in("not have write access", stderr) # restore permissions so the dir will get cleaned up run_in('chmod 777 "{prefix_bin_path}"'.format(prefix_bin_path=prefix_bin_path), shell)
def test_activate_root_simple(shell): # if shell == "bash.exe" and datetime.now() < datetime(2017, 5, 1): # pytest.xfail("fix this soon") shell_vars = _format_vars(shell) with TemporaryDirectory(prefix=ENVS_PREFIX, dir=dirname(__file__)) as envs: commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate" root {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_in( shells[shell]['pathsep'].join(_envpaths(root_dir, shell=shell)), stdout, stderr) commands = (shell_vars['command_setup'] + """ {source} "{syspath}{binpath}activate" root {source} "{syspath}{binpath}deactivate" {printpath} """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) stdout = strip_leading_library_bin(stdout, shells[shell]) assert_equals(stdout, u"%s" % shell_vars['base_path'])
def test_info(): conda_info_out, conda_info_err, rc = run_command(Commands.INFO) assert_equals(conda_info_err, '') for name in ['platform', 'conda version', 'envs directories', 'package cache', 'channel URLs', 'config file', 'offline mode']: assert_in(name, conda_info_out) conda_info_e_out, conda_info_e_err, rc = run_command(Commands.INFO, '-e') assert_in('base', conda_info_e_out) assert_equals(conda_info_e_err, '') conda_info_s_out, conda_info_s_err, rc = run_command(Commands.INFO, '-s') assert_equals(conda_info_s_err, '') for name in ['sys.version', 'sys.prefix', 'sys.executable', 'conda location', 'conda-build', 'PATH']: assert_in(name, conda_info_s_out) conda_info_all_out, conda_info_all_err, rc = run_command(Commands.INFO, '--all') assert_equals(conda_info_all_err, '') assert_in(conda_info_out, conda_info_all_out) assert_in(conda_info_e_out, conda_info_all_out) assert_in(conda_info_s_out, conda_info_all_out)
def test_info(): conda_info_out, conda_info_err, rc = run_command(Commands.INFO) assert_equals(conda_info_err, '') for name in [ 'platform', 'conda version', 'envs directories', 'package cache', 'channel URLs', 'config file', 'offline mode' ]: assert_in(name, conda_info_out) conda_info_e_out, conda_info_e_err, rc = run_command(Commands.INFO, '-e') assert_in('base', conda_info_e_out) assert_equals(conda_info_e_err, '') conda_info_s_out, conda_info_s_err, rc = run_command(Commands.INFO, '-s') assert_equals(conda_info_s_err, '') for name in [ 'sys.version', 'sys.prefix', 'sys.executable', 'conda location', 'conda-build', 'PATH' ]: assert_in(name, conda_info_s_out) conda_info_all_out, conda_info_all_err, rc = run_command( Commands.INFO, '--all') assert_equals(conda_info_all_err, '') assert_in(conda_info_out, conda_info_all_out) assert_in(conda_info_e_out, conda_info_all_out) assert_in(conda_info_s_out, conda_info_all_out)
def test_activate_help(shell): shell_vars = _format_vars(shell) with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs: if not platform.startswith("win"): commands = (shell_vars['command_setup'] + """ "{syspath}{cmd_path}activate" Zanzibar """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, '') assert_in("activate must be sourced", stderr) assert_in("Usage: source activate ENV", stderr) commands = (shell_vars['command_setup'] + """ {source} "{syspath}{cmd_path}activate" --help """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, '') if platform.startswith("win") and shell in ["cmd.exe", "powershell"]: assert_in("Usage: activate ENV", stderr) else: assert_in("Usage: source activate ENV", stderr) commands = (shell_vars['command_setup'] + """ {syspath}{cmd_path}deactivate """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, '') assert_in("deactivate must be sourced", stderr) assert_in("Usage: source deactivate", stderr) commands = (shell_vars['command_setup'] + """ {source} {syspath}{cmd_path}deactivate --help """).format(envs=envs, **shell_vars) stdout, stderr = run_in(commands, shell) assert_equals(stdout, '') if platform == 'win' and shell in ["cmd.exe", "powershell"]: assert_in("Usage: deactivate", stderr) else: assert_in("Usage: source deactivate", stderr)
def test_info(): conda_info_out, conda_info_err, rc = run_command(Commands.INFO) assert_equals(conda_info_err, '') for name in [ 'platform', 'conda version', 'envs directories', 'package cache', 'channel URLs', 'config file', 'offline mode' ]: assert_in(name, conda_info_out) conda_info_e_out, conda_info_e_err, rc = run_command(Commands.INFO, '-e') assert_in('base', conda_info_e_out) assert_equals(conda_info_e_err, '') conda_info_s_out, conda_info_s_err, rc = run_command(Commands.INFO, '-s') assert_equals(conda_info_s_err, '') for name in [ 'sys.version', 'sys.prefix', 'sys.executable', 'conda location', 'conda-build', 'CONDA_DEFAULT_ENV', 'PATH', 'PYTHONPATH' ]: assert_in(name, conda_info_s_out) if context.platform == 'linux': assert_in('LD_LIBRARY_PATH', conda_info_s_out) if context.platform == 'osx': assert_in('DYLD_LIBRARY_PATH', conda_info_s_out) conda_info_all_out, conda_info_all_err, rc = run_command( Commands.INFO, '--all') assert_equals(conda_info_all_err, '') assert_in(conda_info_out, conda_info_all_out) assert_in(conda_info_e_out, conda_info_all_out) assert_in(conda_info_s_out, conda_info_all_out)
def test_info(): conda_info_out, conda_info_err = run_conda_command('info') assert_equals(conda_info_err, '') for name in ['platform', 'conda version', 'root environment', 'default environment', 'envs directories', 'package cache', 'channel URLs', 'config file', 'is foreign system']: assert_in(name, conda_info_out) conda_info_e_out, conda_info_e_err = run_conda_command('info', '-e') assert_in('root', conda_info_e_out) assert_equals(conda_info_e_err, '') conda_info_s_out, conda_info_s_err = run_conda_command('info', '-s') assert_equals(conda_info_s_err, '') for name in ['sys.version', 'sys.prefix', 'sys.executable', 'conda location', 'conda-build', 'CIO_TEST', 'CONDA_DEFAULT_ENV', 'PATH', 'PYTHONPATH']: assert_in(name, conda_info_s_out) if config.platform == 'linux': assert_in('LD_LIBRARY_PATH', conda_info_s_out) if config.platform == 'osx': assert_in('DYLD_LIBRARY_PATH', conda_info_s_out) conda_info_all_out, conda_info_all_err = run_conda_command('info', '--all') assert_equals(conda_info_all_err, '') assert_in(conda_info_out, conda_info_all_out) assert_in(conda_info_e_out, conda_info_all_out) assert_in(conda_info_s_out, conda_info_all_out)
def test_info(): conda_info_out, conda_info_err = run_conda_command('info') assert_equals(conda_info_err, '') for name in [ 'platform', 'conda version', 'root environment', 'default environment', 'envs directories', 'package cache', 'channel URLs', 'config file', 'is foreign system' ]: assert_in(name, conda_info_out) conda_info_e_out, conda_info_e_err = run_conda_command('info', '-e') assert_in('root', conda_info_e_out) assert_equals(conda_info_e_err, '') conda_info_s_out, conda_info_s_err = run_conda_command('info', '-s') assert_equals(conda_info_s_err, '') for name in [ 'sys.version', 'sys.prefix', 'sys.executable', 'conda location', 'conda-build', 'CIO_TEST', 'CONDA_DEFAULT_ENV', 'PATH', 'PYTHONPATH' ]: assert_in(name, conda_info_s_out) if config.platform == 'linux': assert_in('LD_LIBRARY_PATH', conda_info_s_out) if config.platform == 'osx': assert_in('DYLD_LIBRARY_PATH', conda_info_s_out) conda_info_all_out, conda_info_all_err = run_conda_command('info', '--all') assert_equals(conda_info_all_err, '') assert_in(conda_info_out, conda_info_all_out) assert_in(conda_info_e_out, conda_info_all_out) assert_in(conda_info_s_out, conda_info_all_out)