コード例 #1
0
def collect_rc():
    rc = {}
    if isfile(user_rc_path):
        with open(user_rc_path) as fh:
            rc.update(yaml_load(fh.read()))

    if isfile(sys_rc_path):
        with open(sys_rc_path) as fh:
            rc.update(yaml_load(fh.read()))

    return rc
コード例 #2
0
ファイル: test_config.py プロジェクト: totalSozluk/conda
def test_config_command_remove_force():
    # Finally, test --remove, --remove-key
    with make_temp_condarc() as rc:
        run_command(Commands.CONFIG, '--file', rc, '--add', 'channels', 'test')
        run_command(Commands.CONFIG, '--file', rc, '--set', 'always_yes',
                    'true')
        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file',
                                                  rc, '--remove', 'channels',
                                                  'test')
        assert stdout == stderr == ''
        assert yaml_load(_read_test_condarc(rc)) == {
            'channels': ['defaults'],
            'always_yes': True
        }

        stdout, stderr, return_code = run_command(Commands.CONFIG,
                                                  '--file',
                                                  rc,
                                                  '--remove',
                                                  'channels',
                                                  'test',
                                                  use_exception_handler=True)
        assert stdout == ''
        assert "CondaKeyError: 'channels': 'test' is not in the 'channels' " \
               "key of the config file" in stderr

        stdout, stderr, return_code = run_command(Commands.CONFIG,
                                                  '--file',
                                                  rc,
                                                  '--remove',
                                                  'disallow',
                                                  'python',
                                                  use_exception_handler=True)
        assert stdout == ''
        assert "CondaKeyError: 'disallow': key 'disallow' " \
               "is not in the config file" in stderr

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file',
                                                  rc, '--remove-key',
                                                  'always_yes')
        assert stdout == stderr == ''
        assert yaml_load(_read_test_condarc(rc)) == {'channels': ['defaults']}

        stdout, stderr, return_code = run_command(Commands.CONFIG,
                                                  '--file',
                                                  rc,
                                                  '--remove-key',
                                                  'always_yes',
                                                  use_exception_handler=True)

        assert stdout == ''
        assert "CondaKeyError: 'always_yes': key 'always_yes' " \
               "is not in the config file" in stderr
コード例 #3
0
ファイル: test_channel.py プロジェクト: dhirschfeld/conda
    def setUp(cls):
        string = dals("""
        custom_channels:
          darwin: https://some.url.somewhere/stuff
          chuck: http://user1:[email protected]:8080/t/tk-1234/with/path
          pkgs/anaconda: http://192.168.0.15:8080
        migrated_custom_channels:
          darwin: s3://just/cant
          chuck: file:///var/lib/repo/
          pkgs/anaconda: https://repo.anaconda.com
        migrated_channel_aliases:
          - https://conda.anaconda.org
        channel_alias: ftp://new.url:8082
        default_channels:
          - http://192.168.0.15:8080/pkgs/anaconda
          - http://192.168.0.15:8080/pkgs/pro
          - http://192.168.0.15:8080/pkgs/msys2
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir

        cls.DEFAULT_URLS = ['http://192.168.0.15:8080/pkgs/anaconda/%s' % cls.platform,
                            'http://192.168.0.15:8080/pkgs/anaconda/noarch',
                            'http://192.168.0.15:8080/pkgs/pro/%s' % cls.platform,
                            'http://192.168.0.15:8080/pkgs/pro/noarch',
                            'http://192.168.0.15:8080/pkgs/msys2/%s' % cls.platform,
                            'http://192.168.0.15:8080/pkgs/msys2/noarch',
                            ]
コード例 #4
0
 def setUp(self):
     string = dals("""
     custom_channels:
       darwin: https://some.url.somewhere/stuff
       chuck: http://another.url:8080/with/path
     custom_multichannels:
       michele:
         - https://do.it.with/passion
         - learn_from_every_thing
       steve:
         - more-downloads
     migrated_custom_channels:
       darwin: s3://just/cant
       chuck: file:///var/lib/repo/
     migrated_channel_aliases:
       - https://conda.anaconda.org
     channel_alias: ftp://new.url:8082
     conda-build:
       root-dir: /some/test/path
     proxy_servers:
       http: http://user:[email protected]:8080
       https: none
       ftp:
       sftp: ''
       ftps: false
       rsync: 'false'
     aggressive_update_packages: []
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters(
         'testdata', yaml_load(string)))
     context._set_raw_data(rd)
コード例 #5
0
def from_yaml(yamlstr, **kwargs):
    """Load and return a ``Environment`` from a given ``yaml string``"""
    data = yaml_load(yamlstr)
    if kwargs is not None:
        for key, value in kwargs.items():
            data[key] = value
    return Environment(**data)
コード例 #6
0
    def setUp(cls):
        string = dals("""
        custom_channels:
          darwin: https://some.url.somewhere/stuff
          chuck: http://user1:[email protected]:8080/t/tk-1234/with/path
          pkgs/anaconda: http://192.168.0.15:8080
        migrated_custom_channels:
          darwin: s3://just/cant
          chuck: file:///var/lib/repo/
          pkgs/anaconda: https://repo.continuum.io
        migrated_channel_aliases:
          - https://conda.anaconda.org
        channel_alias: ftp://new.url:8082
        default_channels:
          - http://192.168.0.15:8080/pkgs/anaconda
          - http://192.168.0.15:8080/pkgs/pro
          - http://192.168.0.15:8080/pkgs/msys2
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir

        cls.DEFAULT_URLS = ['http://192.168.0.15:8080/pkgs/anaconda/%s' % cls.platform,
                            'http://192.168.0.15:8080/pkgs/anaconda/noarch',
                            'http://192.168.0.15:8080/pkgs/pro/%s' % cls.platform,
                            'http://192.168.0.15:8080/pkgs/pro/noarch',
                            'http://192.168.0.15:8080/pkgs/msys2/%s' % cls.platform,
                            'http://192.168.0.15:8080/pkgs/msys2/noarch',
                            ]
コード例 #7
0
ファイル: test_env.py プロジェクト: ychao1983/conda
    def test_create_advanced_pip(self):
        with make_temp_envs_dir() as envs_dir:
            with env_vars(
                {
                    'CONDA_ENVS_DIRS': envs_dir,
                    'CONDA_DLL_SEARCH_MODIFICATION_ENABLE': 'true',
                },
                    stack_callback=conda_tests_ctxt_mgmt_def_pol):
                env_name = str(uuid4())[:8]
                run_command(Commands.CREATE, env_name,
                            support_file('pip_argh.yml'))
                out_file = join(envs_dir, 'test_env.yaml')

            # make sure that the export reconsiders the presence of pip interop being enabled
            PrefixData._cache_.clear()

            with env_vars({
                    'CONDA_ENVS_DIRS': envs_dir,
            },
                          stack_callback=conda_tests_ctxt_mgmt_def_pol):
                # note: out of scope of pip interop var.  Should be enabling conda pip interop itself.
                run_command(Commands.EXPORT, env_name, out_file)
                with open(out_file) as f:
                    d = yaml_load(f)
                assert {'pip': ['argh==0.26.2']} in d['dependencies']
コード例 #8
0
ファイル: test_context.py プロジェクト: groutr/conda
 def setUp(self):
     string = dals("""
     custom_channels:
       darwin: https://some.url.somewhere/stuff
       chuck: http://another.url:8080/with/path
     custom_multichannels:
       michele:
         - https://do.it.with/passion
         - learn_from_every_thing
       steve:
         - more-downloads
     migrated_custom_channels:
       darwin: s3://just/cant
       chuck: file:///var/lib/repo/
     migrated_channel_aliases:
       - https://conda.anaconda.org
     channel_alias: ftp://new.url:8082
     conda-build:
       root-dir: /some/test/path
     proxy_servers:
       http: http://user:[email protected]:8080
       https: none
       ftp:
       sftp: ''
       ftps: false
       rsync: 'false'
     aggressive_update_packages: []
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
     context._set_raw_data(rd)
コード例 #9
0
ファイル: test_config.py プロジェクト: groutr/conda
def test_config_command_show():
    # test alphabetical yaml output
    with make_temp_condarc() as rc:
        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc, '--show')
        output_keys = yaml_load(stdout).keys()

        assert stderr == ''
        assert sorted(output_keys) == [item for item in output_keys]
コード例 #10
0
ファイル: test_configuration.py プロジェクト: conda/conda
 def test_map_parameter_must_be_map(self):
     # regression test for conda/conda#3467
     string = dals("""
     proxy_servers: bad values
     """)
     data = odict(s1=YamlRawParameter.make_raw_parameters('s1', yaml_load(string)))
     config = SampleConfiguration()._set_raw_data(data)
     raises(InvalidTypeError, config.validate_all)
コード例 #11
0
ファイル: test_config.py プロジェクト: PaulGureghian1/Conda
def test_config_command_show():
    # test alphabetical yaml output
    with make_temp_condarc() as rc:
        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc, '--show')
        output_keys = yaml_load(stdout).keys()

        assert stderr == ''
        assert sorted(output_keys) == [item for item in output_keys]
コード例 #12
0
ファイル: test_context.py プロジェクト: squidnee/conda
 def test_client_ssl_cert(self):
     string = dals("""
     client_ssl_cert_key: /some/key/path
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
     context._set_raw_data(rd)
     pytest.raises(ValidationError, context.validate_configuration)
コード例 #13
0
ファイル: test_context.py プロジェクト: groutr/conda
 def test_client_ssl_cert(self):
     string = dals("""
     client_ssl_cert_key: /some/key/path
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
     context._set_raw_data(rd)
     pytest.raises(ValidationError, context.validate_configuration)
コード例 #14
0
 def test_map_parameter_must_be_map(self):
     # regression test for conda/conda#3467
     string = dals("""
     proxy_servers: bad values
     """)
     data = odict(
         s1=YamlRawParameter.make_raw_parameters('s1', yaml_load(string)))
     config = SampleConfiguration()._set_raw_data(data)
     raises(InvalidTypeError, config.validate_all)
コード例 #15
0
ファイル: test_config.py プロジェクト: totalSozluk/conda
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, return_code = run_command(Commands.CONFIG, '--file',
                                                  rc, '--set', 'always_yes',
                                                  'yes')
        assert stdout == ''
        assert stderr == ''
        with open(rc) as fh:
            content = yaml_load(fh.read())
            assert content['always_yes'] is True

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file',
                                                  rc, '--set', 'always_yes',
                                                  'no')
        assert stdout == ''
        assert stderr == ''
        with open(rc) as fh:
            content = yaml_load(fh.read())
            assert content['always_yes'] is False

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file',
                                                  rc, '--set',
                                                  'proxy_servers.http',
                                                  '1.2.3.4:5678')
        assert stdout == ''
        assert stderr == ''
        with open(rc) as fh:
            content = yaml_load(fh.read())
            assert content['always_yes'] is False
            assert content['proxy_servers'] == {'http': '1.2.3.4:5678'}

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file',
                                                  rc, '--set', 'ssl_verify',
                                                  'false')
        assert stdout == ''
        assert stderr == ''

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file',
                                                  rc, '--get', 'ssl_verify')
        assert stdout.strip() == '--set ssl_verify False'
        assert stderr == ''
コード例 #16
0
    def setUpClass(cls):
        string = dals("""
        channel_alias: https://10.2.3.4:8080/conda/t/tk-123-45
        migrated_channel_aliases:
          - https://conda.anaconda.org
          - http://10.2.3.4:7070/conda
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
コード例 #17
0
ファイル: test_channel.py プロジェクト: dhirschfeld/conda
    def setUpClass(cls):
        string = dals("""
        channel_alias: https://10.2.3.4:8080/conda/t/tk-123-45
        migrated_channel_aliases:
          - https://conda.anaconda.org
          - http://10.2.3.4:7070/conda
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
コード例 #18
0
ファイル: test_channel.py プロジェクト: dhirschfeld/conda
    def setUpClass(cls):
        string = dals("""
        default_channels:
           - http://test/conda/anaconda
        channels:
           - http://test/conda/anaconda-cluster
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
コード例 #19
0
ファイル: test_channel.py プロジェクト: stebr1/CheckTime
    def setUpClass(cls):
        string = dals("""
        default_channels:
           - http://test/conda/anaconda
        channels:
           - http://test/conda/anaconda-cluster
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
コード例 #20
0
ファイル: test_config.py プロジェクト: groutr/conda
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, return_code = run_command(Commands.CONFIG, '--file', rc,
                                                  '--set', 'always_yes', 'yes')
        assert stdout == ''
        assert stderr == ''
        with open(rc) as fh:
            content = yaml_load(fh.read())
            assert content['always_yes'] is True

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc,
                                                  '--set', 'always_yes', 'no')
        assert stdout == ''
        assert stderr == ''
        with open(rc) as fh:
            content = yaml_load(fh.read())
            assert content['always_yes'] is False

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc,
                                                  '--set', 'proxy_servers.http', '1.2.3.4:5678')
        assert stdout == ''
        assert stderr == ''
        with open(rc) as fh:
            content = yaml_load(fh.read())
            assert content['always_yes'] is False
            assert content['proxy_servers'] == {'http': '1.2.3.4:5678'}

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc,
                                                  '--set', 'ssl_verify', 'false')
        assert stdout == ''
        assert stderr == ''

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc,
                                                  '--get', 'ssl_verify')
        assert stdout.strip() == '--set ssl_verify False'
        assert stderr == ''
コード例 #21
0
ファイル: test_env.py プロジェクト: steffenvan/conda
    def test_to_yaml_returns_yaml_parseable_string(self):
        random_name = 'random{}'.format(random.randint(100, 200))
        e = env.Environment(name=random_name,
                            channels=['javascript'],
                            dependencies=['nodejs'])

        expected = {
            'name': random_name,
            'channels': ['javascript'],
            'dependencies': ['nodejs']
        }

        actual = yaml_load(StringIO(e.to_yaml()))
        self.assertEqual(expected, actual)
コード例 #22
0
def test_yaml_complex():
    test_string = dals("""
    single_bool: false
    single_str: no

    # comment here
    a_seq_1:
      - 1
      - 2
      - 3

    a_seq_2:
      - 1  # with comment
      - two: 2
      - 3

    a_map:
      # comment
      field1: true
      field2: yes

    # final comment
    """)

    python_structure = {
        'single_bool': False,
        'single_str': 'no',
        'a_seq_1': [
            1,
            2,
            3,
        ],
        'a_seq_2': [
            1,
            {'two': 2},
            3,
        ],
        'a_map': {
            'field1': True,
            'field2': 'yes',
        },
    }

    loaded_from_string = yaml_load(test_string)
    assert python_structure == loaded_from_string

    dumped_from_load = yaml_dump(loaded_from_string)
    print(dumped_from_load)
    assert dumped_from_load == test_string
コード例 #23
0
ファイル: test_config.py プロジェクト: groutr/conda
def test_config_command_remove_force():
    # Finally, test --remove, --remove-key
    with make_temp_condarc() as rc:
        run_command(Commands.CONFIG, '--file', rc, '--add',
                          'channels', 'test')
        run_command(Commands.CONFIG, '--file', rc, '--set',
                          'always_yes', 'true')
        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc,
                                           '--remove', 'channels', 'test')
        assert stdout == stderr == ''
        assert yaml_load(_read_test_condarc(rc)) == {'channels': ['defaults'],
                                                     'always_yes': True}

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc,
                                           '--remove', 'channels', 'test', use_exception_handler=True)
        assert stdout == ''
        assert "CondaKeyError: 'channels': 'test' is not in the 'channels' " \
               "key of the config file" in stderr

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc,
                                           '--remove', 'disallow', 'python', use_exception_handler=True)
        assert stdout == ''
        assert "CondaKeyError: 'disallow': key 'disallow' " \
               "is not in the config file" in stderr

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc,
                                           '--remove-key', 'always_yes')
        assert stdout == stderr == ''
        assert yaml_load(_read_test_condarc(rc)) == {'channels': ['defaults']}

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc,
                                           '--remove-key', 'always_yes', use_exception_handler=True)

        assert stdout == ''
        assert "CondaKeyError: 'always_yes': key 'always_yes' " \
               "is not in the config file" in stderr
コード例 #24
0
ファイル: test_channel.py プロジェクト: dhirschfeld/conda
 def setUpClass(cls):
     channels_config = dals("""
     channels:
       - http://user22:[email protected]:8080
       
     whitelist_channels:
       - http://user22:[email protected]:8080
     
     custom_channels:
       unexpanded: http://user1:[email protected]:8080/with/path/t/tk-1234
       expanded: http://user33:[email protected]:8080/with/path/t/tk-1234
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(channels_config)))
     context._set_raw_data(rd)
コード例 #25
0
ファイル: test_channel.py プロジェクト: stebr1/CheckTime
 def setUpClass(cls):
     channels_config = dals("""
     channels:
       - http://user22:[email protected]:8080
       
     whitelist_channels:
       - http://user22:[email protected]:8080
     
     custom_channels:
       unexpanded: http://user1:[email protected]:8080/with/path/t/tk-1234
       expanded: http://user33:[email protected]:8080/with/path/t/tk-1234
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(channels_config)))
     context._set_raw_data(rd)
コード例 #26
0
ファイル: test_env.py プロジェクト: conda/conda
    def test_to_yaml_returns_yaml_parseable_string(self):
        random_name = 'random{}'.format(random.randint(100, 200))
        e = env.Environment(
            name=random_name,
            channels=['javascript'],
            dependencies=['nodejs']
        )

        expected = {
            'name': random_name,
            'channels': ['javascript'],
            'dependencies': ['nodejs']
        }

        actual = yaml_load(StringIO(e.to_yaml()))
        self.assertEqual(expected, actual)
コード例 #27
0
    def setUpClass(cls):
        string = dals("""
        custom_channels:
          chuck: http://user1:[email protected]:8080/with/path/t/tk-1234
          chuck/subchan: http://user33:[email protected]:8080/with/path/t/tk-1234
        channel_alias: ftp://nm:[email protected]:8082/t/zyx-wvut/
        channels:
          - mickey
          - https://conda.anaconda.cloud/t/tk-12-token/minnie
          - http://dont-do:[email protected]/daffy/label/main
        default_channels:
          - http://192.168.0.15:8080/pkgs/anaconda
          - donald/label/main
          - http://us:[email protected]:8080/t/tkn-123/pkgs/r
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
コード例 #28
0
ファイル: test_channel.py プロジェクト: dhirschfeld/conda
    def setUpClass(cls):
        string = dals("""
        custom_channels:
          chuck: http://user1:[email protected]:8080/with/path/t/tk-1234
          chuck/subchan: http://user33:[email protected]:8080/with/path/t/tk-1234
        channel_alias: ftp://nm:[email protected]:8082/t/zyx-wvut/
        channels:
          - mickey
          - https://conda.anaconda.cloud/t/tk-12-token/minnie
          - http://dont-do:[email protected]/daffy/label/main
        default_channels:
          - http://192.168.0.15:8080/pkgs/anaconda
          - donald/label/main
          - http://us:[email protected]:8080/t/tkn-123/pkgs/r
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
コード例 #29
0
ファイル: test_env.py プロジェクト: conda/conda
    def test_create_advanced_pip(self):
        with make_temp_envs_dir() as envs_dir:
            with env_vars({
                'CONDA_ENVS_DIRS': envs_dir,
                'CONDA_DLL_SEARCH_MODIFICATION_ENABLE': 'true',
            }, stack_callback=conda_tests_ctxt_mgmt_def_pol):
                env_name = str(uuid4())[:8]
                run_command(Commands.CREATE, env_name,
                            support_file('pip_argh.yml'))
                out_file = join(envs_dir, 'test_env.yaml')

            # make sure that the export reconsiders the presence of pip interop being enabled
            PrefixData._cache_.clear()

            with env_vars({
                'CONDA_ENVS_DIRS': envs_dir,
            }, stack_callback=conda_tests_ctxt_mgmt_def_pol):
                # note: out of scope of pip interop var.  Should be enabling conda pip interop itself.
                run_command(Commands.EXPORT, env_name, out_file)
                with open(out_file) as f:
                    d = yaml_load(f)
                assert {'pip': ['argh==0.26.2']} in d['dependencies']
コード例 #30
0
    def test_create_advanced_pip(self):
        with make_temp_envs_dir() as envs_dir:
            with env_vars({
                'CONDA_ENVS_DIRS': envs_dir,
                'CONDA_PIP_INTEROP_ENABLED': 'true',
            }, reset_context):
                env_name = str(uuid4())[:8]
                prefix = join(envs_dir, env_name)
                python_path = join(prefix, PYTHON_BINARY)
                run_command(Commands.CREATE, env_name,
                            support_file('pip_argh.yml'))
                out_file = join(envs_dir, 'test_env.yaml')

            # make sure that the export reconsiders the presence of pip interop being enabled
            PrefixData._cache_.clear()

            with env_vars({
                'CONDA_ENVS_DIRS': envs_dir,
            }, reset_context):
                # note: out of scope of pip interop var.  Should be enabling conda pip interop itself.
                run_command(Commands.EXPORT, env_name, out_file)
                with open(out_file) as f:
                    d = yaml_load(f)
                assert {'pip': ['argh==0.26.2']} in d['dependencies']
コード例 #31
0
ファイル: test_configuration.py プロジェクト: conda/conda
def load_from_string_data(*seq):
    return odict((f, YamlRawParameter.make_raw_parameters(f, yaml_load(test_yaml_raw[f])))
                 for f in seq)
コード例 #32
0
def test_dump():
    obj = dict([
        ('a_seq', [1, 2, 3]),
        ('a_map', {'a_key': 'a_value'}),
    ])
    assert obj == yaml_load(yaml_dump(obj))
コード例 #33
0
ファイル: test_config.py プロジェクト: totalSozluk/conda
def test_config_command_parser():
    # Now test the YAML "parser"
    # Channels is normal content.
    # create_default_packages has extra spaces in list items
    condarc = """\
channels:
  - test
  - defaults

create_default_packages :
  -  ipython
  -  numpy

changeps1: false

# Here is a comment
always_yes: true
"""
    # First verify that this itself is valid YAML
    assert yaml_load(condarc) == {
        'channels': ['test', 'defaults'],
        'create_default_packages': ['ipython', 'numpy'],
        'changeps1': False,
        'always_yes': True
    }

    with make_temp_condarc(condarc) as rc:
        stdout, stderr, return_code = run_command(Commands.CONFIG,
                                                  '--file',
                                                  rc,
                                                  '--get',
                                                  use_exception_handler=True)
        print(stdout)
        assert stdout.strip() == """\
--set always_yes True
--set changeps1 False
--add channels 'defaults'   # lowest priority
--add channels 'test'   # highest priority
--add create_default_packages 'numpy'
--add create_default_packages 'ipython'\
"""
        with open(rc, 'r') as fh:
            print(fh.read())

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file',
                                                  rc, '--prepend', 'channels',
                                                  'mychannel')
        assert stdout == stderr == ''

        with open(rc, 'r') as fh:
            print(fh.read())

        assert _read_test_condarc(rc) == """\
channels:
  - mychannel
  - test
  - defaults

create_default_packages:
  - ipython
  - numpy

changeps1: false

# Here is a comment
always_yes: true
"""

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file',
                                                  rc, '--set', 'changeps1',
                                                  'true')

        assert stdout == stderr == ''

        assert _read_test_condarc(rc) == """\
channels:
  - mychannel
  - test
  - defaults

create_default_packages:
  - ipython
  - numpy

changeps1: true

# Here is a comment
always_yes: true
"""

        # Test adding a new list key. We couldn't test this above because it
        # doesn't work yet with odd whitespace
    condarc = """\
channels:
  - test
  - defaults

always_yes: true
"""

    with make_temp_condarc(condarc) as rc:
        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file',
                                                  rc, '--add', 'disallow',
                                                  'perl')
        assert stdout == stderr == ''
        assert _read_test_condarc(rc) == condarc + """\
コード例 #34
0
def load_from_string_data(*seq):
    return odict(
        (f,
         YamlRawParameter.make_raw_parameters(f, yaml_load(test_yaml_raw[f])))
        for f in seq)
コード例 #35
0
ファイル: test_config.py プロジェクト: groutr/conda
def test_config_command_parser():
    # Now test the YAML "parser"
    # Channels is normal content.
    # create_default_packages has extra spaces in list items
    condarc = """\
channels:
  - test
  - defaults

create_default_packages :
  -  ipython
  -  numpy

changeps1: false

# Here is a comment
always_yes: true
"""
    # First verify that this itself is valid YAML
    assert yaml_load(condarc) == {'channels': ['test', 'defaults'],
                                  'create_default_packages': ['ipython', 'numpy'],
                                  'changeps1': False,
                                  'always_yes': True}

    with make_temp_condarc(condarc) as rc:
        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc, '--get', use_exception_handler=True)
        print(stdout)
        assert stdout.strip() == """\
--set always_yes True
--set changeps1 False
--add channels 'defaults'   # lowest priority
--add channels 'test'   # highest priority
--add create_default_packages 'numpy'
--add create_default_packages 'ipython'\
"""
        with open(rc, 'r') as fh:
            print(fh.read())

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc, '--prepend',
                                                  'channels', 'mychannel')
        assert stdout == stderr == ''

        with open(rc, 'r') as fh:
            print(fh.read())

        assert _read_test_condarc(rc) == """\
channels:
  - mychannel
  - test
  - defaults

create_default_packages:
  - ipython
  - numpy

changeps1: false

# Here is a comment
always_yes: true
"""

        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc,
                                           '--set', 'changeps1', 'true')

        assert stdout == stderr == ''

        assert _read_test_condarc(rc)== """\
channels:
  - mychannel
  - test
  - defaults

create_default_packages:
  - ipython
  - numpy

changeps1: true

# Here is a comment
always_yes: true
"""

        # Test adding a new list key. We couldn't test this above because it
        # doesn't work yet with odd whitespace
    condarc = """\
channels:
  - test
  - defaults

always_yes: true
"""

    with make_temp_condarc(condarc) as rc:
        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc, '--add',
                                           'disallowed_packages', 'perl')
        assert stdout == stderr == ''
        assert _read_test_condarc(rc) == condarc + """\