当前位置: 首页>>代码示例>>Python>>正文


Python helpers.run_conda_command函数代码示例

本文整理汇总了Python中tests.helpers.run_conda_command函数的典型用法代码示例。如果您正苦于以下问题:Python run_conda_command函数的具体用法?Python run_conda_command怎么用?Python run_conda_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了run_conda_command函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_set_rc_string

def test_set_rc_string():
    # Test setting string keys in .condarc

    # We specifically test ssl_verify since it can be either a boolean or a string
    try:
        stdout, stderr = run_conda_command('config', '--file', test_condarc,
                                           '--set', 'ssl_verify', 'yes')
        assert stdout == ''
        assert stderr == ''

        verify = yaml.load(open(test_condarc, 'r'))['ssl_verify']
        assert verify == True

        stdout, stderr = run_conda_command('config', '--file', test_condarc,
                                           '--set', 'ssl_verify', 'test_string.crt')
        assert stdout == ''
        assert stderr == ''

        verify = yaml.load(open(test_condarc, 'r'))['ssl_verify']
        assert verify == 'test_string.crt'


        os.unlink(test_condarc)
    finally:
        try:
            os.unlink(test_condarc)
        except OSError:
            pass
开发者ID:AvdN,项目名称:conda,代码行数:28,代码来源:test_config.py

示例2: test_info

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', 'offline mode']:
        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)
开发者ID:jaimergp,项目名称:conda,代码行数:27,代码来源:test_info.py

示例3: test_config_command_bad_args

def test_config_command_bad_args():
    with make_temp_condarc() as rc:
        stdout, stderr = run_conda_command("config", "--file", rc, "--add", "notarealkey", "test")
        assert stdout == ""

        stdout, stderr = run_conda_command("config", "--file", rc, "--set", "notarealkey", "true")
        assert stdout == ""
开发者ID:conda,项目名称:conda,代码行数:7,代码来源:test_config.py

示例4: test_info

def test_info():
    conda_info_out, conda_info_err = run_conda_command('info')
    assert 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 name in conda_info_out

    conda_info_e_out, conda_info_e_err = run_conda_command('info', '-e')
    assert 'root' in conda_info_e_out
    assert conda_info_e_err == ''

    conda_info_s_out, conda_info_s_err = run_conda_command('info', '-s')
    assert 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 name in conda_info_s_out
    if config.platform == 'linux':
        assert 'LD_LIBRARY_PATH' in conda_info_s_out
    if config.platform == 'osx':
        assert 'DYLD_LIBRARY_PATH' in conda_info_s_out

    conda_info_all_out, conda_info_all_err = run_conda_command('info', '--all')
    assert conda_info_all_err == ''
    assert conda_info_out in conda_info_all_out
    assert conda_info_e_out in conda_info_all_out
    assert conda_info_s_out in conda_info_all_out
开发者ID:525152625,项目名称:conda,代码行数:27,代码来源:test_info.py

示例5: test_config_command_bad_args

def test_config_command_bad_args():
    with make_temp_condarc() as rc:
        stdout, stderr = run_conda_command('config', '--file', rc, '--add',
            'notarealkey', 'test')
        assert stdout == ''

        stdout, stderr = run_conda_command('config', '--file', rc, '--set',
            'notarealkey', 'true')
        assert stdout == ''
开发者ID:arkottke,项目名称:conda,代码行数:9,代码来源:test_config.py

示例6: test_config_command_basics

def test_config_command_basics():

    try:
        # Test that creating the file adds the defaults channel
        assert not os.path.exists('test_condarc')
        stdout, stderr = run_conda_command('config', '--file', test_condarc, '--add',
            'channels', 'test')
        assert stdout == stderr == ''
        assert _read_test_condarc() == """\
channels:
  - test
  - defaults
"""
        os.unlink(test_condarc)

        # When defaults is explicitly given, it should not be added
        stdout, stderr = run_conda_command('config', '--file', test_condarc, '--add',
    'channels', 'test', '--add', 'channels', 'defaults')
        assert stdout == stderr == ''
        assert _read_test_condarc() == """\
channels:
  - defaults
  - test
"""
        os.unlink(test_condarc)

        # Duplicate keys should not be added twice
        stdout, stderr = run_conda_command('config', '--file', test_condarc, '--add',
        'channels', 'test')
        assert stdout == stderr == ''
        stdout, stderr = run_conda_command('config', '--file', test_condarc, '--add',
        'channels', 'test')
        assert stdout == ''
        assert stderr == "Skipping channels: test, item already exists\n"
        assert _read_test_condarc() == """\
channels:
  - test
  - defaults
"""
        os.unlink(test_condarc)

        # Test creating a new file with --set
        stdout, stderr = run_conda_command('config', '--file', test_condarc,
        '--set', 'always_yes', 'yes')
        assert stdout == stderr == ''
        assert _read_test_condarc() == """\
always_yes: yes
"""
        os.unlink(test_condarc)


    finally:
        try:
            pass
            os.unlink(test_condarc)
        except OSError:
            pass
开发者ID:AvdN,项目名称:conda,代码行数:57,代码来源:test_config.py

示例7: test_config_command_remove_force

def test_config_command_remove_force():
    # Finally, test --remove, --remove-key
    with make_temp_condarc() as rc:
        run_conda_command('config', '--file', rc, '--add',
            'channels', 'test')
        run_conda_command('config', '--file', rc, '--set',
            'always_yes', 'true')
        stdout, stderr = run_conda_command('config', '--file', rc,
            '--remove', 'channels', 'test')
        assert stdout == stderr == ''
        assert yaml.load(_read_test_condarc(rc), Loader=yaml.RoundTripLoader) == {'channels': ['defaults'],
            'always_yes': True}

        stdout, stderr = run_conda_command('config', '--file', rc,
            '--remove', 'channels', 'test', '--force')
        assert stdout == ''
        assert stderr == "Key error: 'test' is not in the 'channels' key of the config file"

        stdout, stderr = run_conda_command('config', '--file', rc,
            '--remove', 'disallow', 'python', '--force')
        assert stdout == ''
        assert stderr == "Key error: key 'disallow' is not in the config file"

        stdout, stderr = run_conda_command('config', '--file', rc,
            '--remove-key', 'always_yes', '--force')
        assert stdout == stderr == ''
        assert yaml.load(_read_test_condarc(rc), Loader=yaml.RoundTripLoader) == {'channels': ['defaults']}

        stdout, stderr = run_conda_command('config', '--file', rc,
            '--remove-key', 'always_yes', '--force')

        assert stdout == ''
        assert stderr == "Key error: key 'always_yes' is not in the config file"
开发者ID:Zibi92,项目名称:conda,代码行数:33,代码来源:test_config.py

示例8: test_config_command_remove_force

def test_config_command_remove_force():
    # Finally, test --remove, --remove-key
    with make_temp_condarc() as rc:
        run_conda_command("config", "--file", rc, "--add", "channels", "test")
        run_conda_command("config", "--file", rc, "--set", "always_yes", "true")
        stdout, stderr = run_conda_command("config", "--file", rc, "--remove", "channels", "test")
        assert stdout == stderr == ""
        assert yaml_load(_read_test_condarc(rc)) == {"channels": ["defaults"], "always_yes": True}

        stdout, stderr = run_conda_command("config", "--file", rc, "--remove", "channels", "test", "--force")
        assert stdout == ""
        assert (
            "CondaKeyError: Error with key 'channels': 'test' is not in the 'channels' "
            "key of the config file" in stderr
        )

        stdout, stderr = run_conda_command("config", "--file", rc, "--remove", "disallow", "python", "--force")
        assert stdout == ""
        assert "CondaKeyError: Error with key 'disallow': key 'disallow' " "is not in the config file" in stderr

        stdout, stderr = run_conda_command("config", "--file", rc, "--remove-key", "always_yes", "--force")
        assert stdout == stderr == ""
        assert yaml_load(_read_test_condarc(rc)) == {"channels": ["defaults"]}

        stdout, stderr = run_conda_command("config", "--file", rc, "--remove-key", "always_yes", "--force")

        assert stdout == ""
        assert "CondaKeyError: Error with key 'always_yes': key 'always_yes' " "is not in the config file" in stderr
开发者ID:conda,项目名称:conda,代码行数:28,代码来源:test_config.py

示例9: test_config_set

def test_config_set():
    # Test the config set command
    # Make sure it accepts only boolean values for boolean keys and any value for string keys

    with make_temp_condarc() as rc:
        stdout, stderr = run_conda_command("config", "--file", rc, "--set", "always_yes", "yes")

        assert stdout == ""
        assert stderr == ""

        stdout, stderr = run_conda_command("config", "--file", rc, "--set", "always_yes", "no")

        assert stdout == ""
        assert stderr == ""
开发者ID:conda,项目名称:conda,代码行数:14,代码来源:test_config.py

示例10: test_invalid_config

def test_invalid_config():
    condarc = """\
fgddgh
channels:
  - test
"""
    try:
        with make_temp_condarc(condarc) as rc:
            rc_path = rc
            run_conda_command("config", "--file", rc, "--add", "channels", "test")
    except LoadError as err:
        error1 = "Load Error: in "
        error2 = "on line 1, column 8. Invalid YAML"
        assert error1 in err.message
        assert error2 in err.message
开发者ID:conda,项目名称:conda,代码行数:15,代码来源:test_config.py

示例11: test_info_package_json

def test_info_package_json():
    out, err = run_conda_command("info", "--json", "numpy=1.11.0=py35_0")
    assert err == ""

    out = json.loads(out)
    assert set(out.keys()) == {"numpy=1.11.0=py35_0"}
    assert len(out["numpy=1.11.0=py35_0"]) == 1
    assert isinstance(out["numpy=1.11.0=py35_0"], list)

    out, err = run_conda_command("info", "--json", "numpy")
    assert err == ""

    out = json.loads(out)
    assert set(out.keys()) == {"numpy"}
    assert len(out["numpy"]) > 1
    assert isinstance(out["numpy"], list)
开发者ID:AnddyWang,项目名称:conda,代码行数:16,代码来源:test_info.py

示例12: test_config_set

def test_config_set():
    # Test the config set command
    # Make sure it accepts only boolean values for boolean keys and any value for string keys

    with make_temp_condarc() as rc:
        stdout, stderr = run_conda_command('config', '--file', rc,
                                           '--set', 'always_yes', 'yes')

        assert stdout == ''
        assert stderr == ''

        stdout, stderr = run_conda_command('config', '--file', rc,
                                           '--set', 'always_yes', 'no')

        assert stdout == ''
        assert stderr == ''
开发者ID:Zibi92,项目名称:conda,代码行数:16,代码来源:test_config.py

示例13: test_invalid_rc

def test_invalid_rc():
    # Some tests for unexpected input in the condarc, like keys that are the
    # wrong type
    try:
        condarc = """\
channels:
"""

        with open(test_condarc, 'w') as f:
            f.write(condarc)

        stdout, stderr = run_conda_command('config', '--file', test_condarc,
            '--add', 'channels', 'test')
        assert stdout == ''
        assert stderr == """\
Error: Could not parse the yaml file. Use -f to use the
yaml parser (this will remove any structure or comments from the existing
.condarc file). Reason: key 'channels' should be a list, not NoneType.
"""
        assert _read_test_condarc() == condarc

        os.unlink(test_condarc)
    finally:
        try:
            pass
            os.unlink(test_condarc)
        except OSError:
            pass
开发者ID:AvdN,项目名称:conda,代码行数:28,代码来源:test_config.py

示例14: test_config_command_show

def test_config_command_show():
    # test alphabetical yaml output
    with make_temp_condarc() as rc:
        stdout, stderr = run_conda_command('config', '--file', rc, '--show')
        output_keys = yaml_load(stdout).keys()

        assert stderr == ''
        assert sorted(output_keys) == [item for item in output_keys]
开发者ID:electronwill,项目名称:conda,代码行数:8,代码来源:test_config.py

示例15: test_config_command_basics

def test_config_command_basics():

        # Test that creating the file adds the defaults channel
    with make_temp_condarc() as rc:
        stdout, stderr = run_conda_command('config', '--file', rc, '--add',
          'channels', 'test')
        assert stdout == stderr == ''
        assert _read_test_condarc(rc) == """\
channels:
  - test
  - defaults
"""
    with make_temp_condarc() as rc:
        # When defaults is explicitly given, it should not be added
        stdout, stderr = run_conda_command('config', '--file', rc, '--add',
            'channels', 'test', '--add', 'channels', 'defaults')
        assert stdout == stderr == ''
        assert _read_test_condarc(rc) == """\
channels:
  - defaults
  - test
"""
    # Duplicate keys should not be added twice
    with make_temp_condarc() as rc:
        stdout, stderr = run_conda_command('config', '--file', rc, '--add',
            'channels', 'test')
        assert stdout == stderr == ''
        stdout, stderr = run_conda_command('config', '--file', rc, '--add',
            'channels', 'test')
        assert stdout == ''
        assert stderr == "Skipping channels: test, item already exists"
        assert _read_test_condarc(rc) == """\
channels:
  - test
  - defaults
"""

    # Test creating a new file with --set
    with make_temp_condarc() as rc:
        stdout, stderr = run_conda_command('config', '--file', rc,
            '--set', 'always_yes', 'true')
        assert stdout == stderr == ''
        assert _read_test_condarc(rc) == """\
开发者ID:ezc,项目名称:conda,代码行数:43,代码来源:test_config.py


注:本文中的tests.helpers.run_conda_command函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。