# (c) 2012-2014 Continuum Analytics, Inc. / http://continuum.io
# All Rights Reserved
#
# conda is distributed under the terms of the BSD 3-clause license.
# Consult LICENSE.txt or http://opensource.org/licenses/BSD-3-Clause.
import os
from os.path import dirname, join, exists
import unittest

import pytest

import conda.config as config
from conda.utils import get_yaml
from conda.compat import iterkeys

from tests.helpers import run_conda_command

yaml = get_yaml()

# use condarc from source tree to run these tests against
config.rc_path = join(dirname(__file__), 'condarc')

def _get_default_urls():
    return ['http://repo.continuum.io/pkgs/free',
            'http://repo.continuum.io/pkgs/pro']
config.get_default_urls = _get_default_urls

# unset CIO_TEST.  This is a Continuum-internal variable that draws packages from an internal server instead of
#     repo.continuum.io
try:
    del os.environ['CIO_TEST']
except KeyError:
    pass


class TestConfig(unittest.TestCase):

    # These tests are mostly to ensure API stability

    def __init__(self, *args, **kwargs):
        config.rc = config.load_condarc(config.rc_path)
        # Otherwise normalization tests will fail if the user is logged into
        # binstar.
        config.rc['add_binstar_token'] = False
        super(TestConfig, self).__init__(*args, **kwargs)

    def test_globals(self):
        self.assertTrue(config.root_dir)
        self.assertTrue(config.pkgs_dirs)
        self.assertTrue(config.envs_dirs)
        self.assertTrue(config.default_prefix)
        self.assertTrue(config.platform)
        self.assertTrue(config.subdir)
        self.assertTrue(config.arch_name)
        self.assertTrue(config.bits in (32, 64))

    def test_pkgs_dir_from_envs_dir(self):
        root_dir = config.root_dir
        root_pkgs = join(root_dir, 'pkgs')
        for pi, po in [
            (join(root_dir, 'envs'), root_pkgs),
            ('/usr/local/foo/envs' if config.platform != 'win' else 'C:\envs',
                '/usr/local/foo/envs/.pkgs' if config.platform != 'win' else 'C:\envs\.pkgs'),
            ]:
            self.assertEqual(config.pkgs_dir_from_envs_dir(pi), po)

    def test_proxy_settings(self):
        self.assertEqual(config.get_proxy_servers(),
                         {'http': 'http://user:pass@corp.com:8080',
                          'https': 'https://user:pass@corp.com:8080'})

    def test_normalize_urls(self):
        current_platform = config.subdir
        assert config.DEFAULT_CHANNEL_ALIAS == 'https://conda.anaconda.org/'
        assert config.rc.get('channel_alias') == 'https://your.repo/'

        for channel in iterkeys(config.normalize_urls(['defaults', 'system',
            'https://anaconda.org/username', 'file:///Users/username/repo',
            'username'])):
            assert (channel.endswith('/%s/' % current_platform) or
                    channel.endswith('/noarch/'))
        self.assertEqual(config.normalize_urls([
            'defaults', 'system', 'https://conda.anaconda.org/username',
            'file:///Users/username/repo', 'username'
            ], 'osx-64'),
            {'file:///Users/username/repo/noarch/': ('file:///Users/username/repo', 6),
             'file:///Users/username/repo/osx-64/': ('file:///Users/username/repo', 6),
             'http://repo.continuum.io/pkgs/free/noarch/': (None, 1),
             'http://repo.continuum.io/pkgs/free/osx-64/': (None, 1),
             'http://repo.continuum.io/pkgs/pro/noarch/': (None, 1),
             'http://repo.continuum.io/pkgs/pro/osx-64/': (None, 1),
             'http://some.custom/channel/noarch/': ('http://some.custom/channel', 3),
             'http://some.custom/channel/osx-64/': ('http://some.custom/channel', 3),
             'https://conda.anaconda.org/username/noarch/': ('https://conda.anaconda.org/username', 5),
             'https://conda.anaconda.org/username/osx-64/': ('https://conda.anaconda.org/username', 5),
             'https://your.repo/binstar_username/noarch/': ('binstar_username', 2),
             'https://your.repo/binstar_username/osx-64/': ('binstar_username', 2),
             'https://your.repo/username/noarch/': ('username', 7),
             'https://your.repo/username/osx-64/': ('username', 7)})


test_condarc = os.path.join(os.path.dirname(__file__), 'test_condarc')
def _read_test_condarc():
    with open(test_condarc) as f:
        return f.read()

# Tests for the conda config command
# FIXME This shoiuld be multiple individual tests
@pytest.mark.slow
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"
        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', 'true')
        assert stdout == stderr == ''
        assert _read_test_condarc() == """\
always_yes: true
"""
        os.unlink(test_condarc)

    finally:
        try:
            pass
            os.unlink(test_condarc)
        except OSError:
            pass


# FIXME Break into multiple tests
@pytest.mark.slow
def test_config_command_get():
    try:
        # Test --get
        with open(test_condarc, 'w') as f:
            f.write("""\
channels:
  - test
  - defaults

create_default_packages:
  - ipython
  - numpy

changeps1: no

always_yes: true

invalid_key: yes

channel_alias: http://alpha.conda.anaconda.org
""")

        stdout, stderr = run_conda_command('config', '--file', test_condarc, '--get')
        assert stdout == """\
--set always_yes True
--set changeps1 no
--set channel_alias http://alpha.conda.anaconda.org
--add channels 'defaults'
--add channels 'test'
--add create_default_packages 'numpy'
--add create_default_packages 'ipython'\
"""
        assert stderr == "unknown key invalid_key"

        stdout, stderr = run_conda_command('config', '--file', test_condarc,
        '--get', 'channels')

        assert stdout == """\
--add channels 'defaults'
--add channels 'test'\
"""
        assert stderr == ""

        stdout, stderr = run_conda_command('config', '--file', test_condarc,
        '--get', 'changeps1')

        assert stdout == """\
--set changeps1 no\
"""
        assert stderr == ""

        stdout, stderr = run_conda_command('config', '--file', test_condarc,
            '--get', 'changeps1', 'channels')

        assert stdout == """\
--set changeps1 no
--add channels 'defaults'
--add channels 'test'\
"""
        assert stderr == ""

        stdout, stderr = run_conda_command('config', '--file', test_condarc,
        '--get', 'allow_softlinks')

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

        stdout, stderr = run_conda_command('config', '--file', test_condarc,
        '--get', 'track_features')

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

        stdout, stderr = run_conda_command('config', '--file', test_condarc,
        '--get', 'invalid_key')

        assert stdout == ""
        assert "invalid choice: 'invalid_key'" in stderr

        stdout, stderr = run_conda_command('config', '--file', test_condarc,
        '--get', 'not_valid_key')

        assert stdout == ""
        assert "invalid choice: 'not_valid_key'" in stderr

        os.unlink(test_condarc)


    finally:
        try:
            pass
            os.unlink(test_condarc)
        except OSError:
            pass


# FIXME Break into multiple tests
@pytest.mark.slow
def test_config_command_parser():
    try:
        # 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: yes
"""
        # First verify that this itself is valid YAML
        assert yaml.load(condarc, Loader=yaml.RoundTripLoader) == {'channels': ['test', 'defaults'],
            'create_default_packages': ['ipython', 'numpy'], 'changeps1':
            False, 'always_yes': 'yes'}

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

        stdout, stderr = run_conda_command('config', '--file', test_condarc, '--get')

        assert stdout == """\
--set always_yes yes
--set changeps1 False
--add channels 'defaults'
--add channels 'test'
--add create_default_packages 'numpy'
--add create_default_packages 'ipython'\
"""

        stdout, stderr = run_conda_command('config', '--file', test_condarc, '--add',
            'channels', 'mychannel')
        assert stdout == stderr == ''

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

create_default_packages:
  - ipython
  - numpy

changeps1: false

# Here is a comment
always_yes: 'yes'
"""

        stdout, stderr = run_conda_command('config', '--file', test_condarc,
            '--set', 'changeps1', 'true')

        assert stdout == stderr == ''

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

create_default_packages:
  - ipython
  - numpy

changeps1: true

# Here is a comment
always_yes: 'yes'
"""

        os.unlink(test_condarc)

        # 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 open(test_condarc, 'w') as f:
            f.write(condarc)

        stdout, stderr = run_conda_command('config', '--file', test_condarc, '--add',
            'disallow', 'perl')
        assert stdout == stderr == ''
        assert _read_test_condarc() == condarc + """\
disallow:
  - perl
"""
        os.unlink(test_condarc)


    finally:
        try:
            pass
            os.unlink(test_condarc)
        except OSError:
            pass


# FIXME Break into multiple tests
@pytest.mark.slow
def test_config_command_remove_force():
    try:
        # Finally, test --remove, --remove-key
        run_conda_command('config', '--file', test_condarc, '--add',
            'channels', 'test')
        run_conda_command('config', '--file', test_condarc, '--set',
            'always_yes', 'true')
        stdout, stderr = run_conda_command('config', '--file', test_condarc,
            '--remove', 'channels', 'test')
        assert stdout == stderr == ''
        assert yaml.load(_read_test_condarc(), Loader=yaml.RoundTripLoader) == {'channels': ['defaults'],
            'always_yes': True}

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

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

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

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

        assert stdout == ''
        assert stderr == "Error: key 'always_yes' is not in the config file"
        os.unlink(test_condarc)

    finally:
        try:
            pass
            os.unlink(test_condarc)
        except OSError:
            pass


# FIXME Break into multiple tests
@pytest.mark.slow
def test_config_command_bad_args():
    try:
        stdout, stderr = run_conda_command('config', '--file', test_condarc, '--add',
            'notarealkey', 'test')
        assert stdout == ''

        assert not exists(test_condarc)

        stdout, stderr = run_conda_command('config', '--file', test_condarc, '--set',
            'notarealkey', 'yes')
        assert stdout == ''

        assert not exists(test_condarc)

    finally:
        try:
            pass
            os.unlink(test_condarc)
        except OSError:
            pass

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

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

    try:
        stdout, stderr = run_conda_command('config', '--file', test_condarc,
                                           '--set', 'always_yes', 'yep')

        assert stdout == ''
        assert stderr == 'Error: Key: always_yes; yep is not a YAML boolean.'

    finally:
        try:
            os.unlink(test_condarc)
        except OSError:
            pass

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'), Loader=yaml.RoundTripLoader)['ssl_verify']
        assert verify == 'yes'

        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'), Loader=yaml.RoundTripLoader)['ssl_verify']
        assert verify == 'test_string.crt'


        os.unlink(test_condarc)
    finally:
        try:
            os.unlink(test_condarc)
        except OSError:
            pass

[((18, 7, 18, 17), 'conda.utils.get_yaml', 'get_yaml', ({}, {}), '()', False, 'from conda.utils import get_yaml\n'), ((21, 22, 21, 39), 'os.path.dirname', 'dirname', ({(21, 30, 21, 38): '__file__'}, {}), '(__file__)', False, 'from os.path import dirname, join, exists\n'), ((102, 28, 102, 53), 'os.path.dirname', 'os.path.dirname', ({(102, 44, 102, 52): '__file__'}, {}), '(__file__)', False, 'import os\n'), ((41, 20, 41, 55), 'conda.config.load_condarc', 'config.load_condarc', ({(41, 40, 41, 54): 'config.rc_path'}, {}), '(config.rc_path)', True, 'import conda.config as config\n'), ((59, 20, 59, 42), 'os.path.join', 'join', ({(59, 25, 59, 33): 'root_dir', (59, 35, 59, 41): '"""pkgs"""'}, {}), "(root_dir, 'pkgs')", False, 'from os.path import dirname, join, exists\n'), ((115, 25, 116, 31), 'tests.helpers.run_conda_command', 'run_conda_command', ({(115, 43, 115, 51): '"""config"""', (115, 53, 115, 61): '"""--file"""', (115, 63, 115, 75): 'test_condarc', (115, 77, 115, 84): '"""--add"""', (116, 12, 116, 22): '"""channels"""', (116, 24, 116, 30): '"""test"""'}, {}), "('config', '--file', test_condarc, '--add', 'channels', 'test'\n    )", False, 'from tests.helpers import run_conda_command\n'), ((123, 8, 123, 31), 'os.unlink', 'os.unlink', ({(123, 18, 123, 30): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((126, 25, 127, 56), 'tests.helpers.run_conda_command', 'run_conda_command', ({(126, 43, 126, 51): '"""config"""', (126, 53, 126, 61): '"""--file"""', (126, 63, 126, 75): 'test_condarc', (126, 77, 126, 84): '"""--add"""', (127, 4, 127, 14): '"""channels"""', (127, 16, 127, 22): '"""test"""', (127, 24, 127, 31): '"""--add"""', (127, 33, 127, 43): '"""channels"""', (127, 45, 127, 55): '"""defaults"""'}, {}), "('config', '--file', test_condarc, '--add', 'channels',\n    'test', '--add', 'channels', 'defaults')", False, 'from tests.helpers import run_conda_command\n'), ((134, 8, 134, 31), 'os.unlink', 'os.unlink', ({(134, 18, 134, 30): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((137, 25, 138, 27), 'tests.helpers.run_conda_command', 'run_conda_command', ({(137, 43, 137, 51): '"""config"""', (137, 53, 137, 61): '"""--file"""', (137, 63, 137, 75): 'test_condarc', (137, 77, 137, 84): '"""--add"""', (138, 8, 138, 18): '"""channels"""', (138, 20, 138, 26): '"""test"""'}, {}), "('config', '--file', test_condarc, '--add', 'channels', 'test'\n    )", False, 'from tests.helpers import run_conda_command\n'), ((140, 25, 141, 27), 'tests.helpers.run_conda_command', 'run_conda_command', ({(140, 43, 140, 51): '"""config"""', (140, 53, 140, 61): '"""--file"""', (140, 63, 140, 75): 'test_condarc', (140, 77, 140, 84): '"""--add"""', (141, 8, 141, 18): '"""channels"""', (141, 20, 141, 26): '"""test"""'}, {}), "('config', '--file', test_condarc, '--add', 'channels', 'test'\n    )", False, 'from tests.helpers import run_conda_command\n'), ((149, 8, 149, 31), 'os.unlink', 'os.unlink', ({(149, 18, 149, 30): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((152, 25, 153, 38), 'tests.helpers.run_conda_command', 'run_conda_command', ({(152, 43, 152, 51): '"""config"""', (152, 53, 152, 61): '"""--file"""', (152, 63, 152, 75): 'test_condarc', (153, 8, 153, 15): '"""--set"""', (153, 17, 153, 29): '"""always_yes"""', (153, 31, 153, 37): '"""true"""'}, {}), "('config', '--file', test_condarc, '--set', 'always_yes',\n    'true')", False, 'from tests.helpers import run_conda_command\n'), ((158, 8, 158, 31), 'os.unlink', 'os.unlink', ({(158, 18, 158, 30): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((192, 25, 192, 85), 'tests.helpers.run_conda_command', 'run_conda_command', ({(192, 43, 192, 51): '"""config"""', (192, 53, 192, 61): '"""--file"""', (192, 63, 192, 75): 'test_condarc', (192, 77, 192, 84): '"""--get"""'}, {}), "('config', '--file', test_condarc, '--get')", False, 'from tests.helpers import run_conda_command\n'), ((204, 25, 205, 28), 'tests.helpers.run_conda_command', 'run_conda_command', ({(204, 43, 204, 51): '"""config"""', (204, 53, 204, 61): '"""--file"""', (204, 63, 204, 75): 'test_condarc', (205, 8, 205, 15): '"""--get"""', (205, 17, 205, 27): '"""channels"""'}, {}), "('config', '--file', test_condarc, '--get', 'channels')", False, 'from tests.helpers import run_conda_command\n'), ((213, 25, 214, 29), 'tests.helpers.run_conda_command', 'run_conda_command', ({(213, 43, 213, 51): '"""config"""', (213, 53, 213, 61): '"""--file"""', (213, 63, 213, 75): 'test_condarc', (214, 8, 214, 15): '"""--get"""', (214, 17, 214, 28): '"""changeps1"""'}, {}), "('config', '--file', test_condarc, '--get', 'changeps1')", False, 'from tests.helpers import run_conda_command\n'), ((221, 25, 222, 45), 'tests.helpers.run_conda_command', 'run_conda_command', ({(221, 43, 221, 51): '"""config"""', (221, 53, 221, 61): '"""--file"""', (221, 63, 221, 75): 'test_condarc', (222, 12, 222, 19): '"""--get"""', (222, 21, 222, 32): '"""changeps1"""', (222, 34, 222, 44): '"""channels"""'}, {}), "('config', '--file', test_condarc, '--get', 'changeps1',\n    'channels')", False, 'from tests.helpers import run_conda_command\n'), ((231, 25, 232, 35), 'tests.helpers.run_conda_command', 'run_conda_command', ({(231, 43, 231, 51): '"""config"""', (231, 53, 231, 61): '"""--file"""', (231, 63, 231, 75): 'test_condarc', (232, 8, 232, 15): '"""--get"""', (232, 17, 232, 34): '"""allow_softlinks"""'}, {}), "('config', '--file', test_condarc, '--get', 'allow_softlinks')", False, 'from tests.helpers import run_conda_command\n'), ((237, 25, 238, 34), 'tests.helpers.run_conda_command', 'run_conda_command', ({(237, 43, 237, 51): '"""config"""', (237, 53, 237, 61): '"""--file"""', (237, 63, 237, 75): 'test_condarc', (238, 8, 238, 15): '"""--get"""', (238, 17, 238, 33): '"""track_features"""'}, {}), "('config', '--file', test_condarc, '--get', 'track_features')", False, 'from tests.helpers import run_conda_command\n'), ((243, 25, 244, 31), 'tests.helpers.run_conda_command', 'run_conda_command', ({(243, 43, 243, 51): '"""config"""', (243, 53, 243, 61): '"""--file"""', (243, 63, 243, 75): 'test_condarc', (244, 8, 244, 15): '"""--get"""', (244, 17, 244, 30): '"""invalid_key"""'}, {}), "('config', '--file', test_condarc, '--get', 'invalid_key')", False, 'from tests.helpers import run_conda_command\n'), ((249, 25, 250, 33), 'tests.helpers.run_conda_command', 'run_conda_command', ({(249, 43, 249, 51): '"""config"""', (249, 53, 249, 61): '"""--file"""', (249, 63, 249, 75): 'test_condarc', (250, 8, 250, 15): '"""--get"""', (250, 17, 250, 32): '"""not_valid_key"""'}, {}), "('config', '--file', test_condarc, '--get', 'not_valid_key')", False, 'from tests.helpers import run_conda_command\n'), ((255, 8, 255, 31), 'os.unlink', 'os.unlink', ({(255, 18, 255, 30): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((295, 25, 295, 85), 'tests.helpers.run_conda_command', 'run_conda_command', ({(295, 43, 295, 51): '"""config"""', (295, 53, 295, 61): '"""--file"""', (295, 63, 295, 75): 'test_condarc', (295, 77, 295, 84): '"""--get"""'}, {}), "('config', '--file', test_condarc, '--get')", False, 'from tests.helpers import run_conda_command\n'), ((306, 25, 307, 36), 'tests.helpers.run_conda_command', 'run_conda_command', ({(306, 43, 306, 51): '"""config"""', (306, 53, 306, 61): '"""--file"""', (306, 63, 306, 75): 'test_condarc', (306, 77, 306, 84): '"""--add"""', (307, 12, 307, 22): '"""channels"""', (307, 24, 307, 35): '"""mychannel"""'}, {}), "('config', '--file', test_condarc, '--add', 'channels',\n    'mychannel')", False, 'from tests.helpers import run_conda_command\n'), ((326, 25, 327, 41), 'tests.helpers.run_conda_command', 'run_conda_command', ({(326, 43, 326, 51): '"""config"""', (326, 53, 326, 61): '"""--file"""', (326, 63, 326, 75): 'test_condarc', (327, 12, 327, 19): '"""--set"""', (327, 21, 327, 32): '"""changeps1"""', (327, 34, 327, 40): '"""true"""'}, {}), "('config', '--file', test_condarc, '--set', 'changeps1',\n    'true')", False, 'from tests.helpers import run_conda_command\n'), ((347, 8, 347, 31), 'os.unlink', 'os.unlink', ({(347, 18, 347, 30): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((362, 25, 363, 31), 'tests.helpers.run_conda_command', 'run_conda_command', ({(362, 43, 362, 51): '"""config"""', (362, 53, 362, 61): '"""--file"""', (362, 63, 362, 75): 'test_condarc', (362, 77, 362, 84): '"""--add"""', (363, 12, 363, 22): '"""disallow"""', (363, 24, 363, 30): '"""perl"""'}, {}), "('config', '--file', test_condarc, '--add', 'disallow', 'perl'\n    )", False, 'from tests.helpers import run_conda_command\n'), ((369, 8, 369, 31), 'os.unlink', 'os.unlink', ({(369, 18, 369, 30): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((385, 8, 386, 31), 'tests.helpers.run_conda_command', 'run_conda_command', ({(385, 26, 385, 34): '"""config"""', (385, 36, 385, 44): '"""--file"""', (385, 46, 385, 58): 'test_condarc', (385, 60, 385, 67): '"""--add"""', (386, 12, 386, 22): '"""channels"""', (386, 24, 386, 30): '"""test"""'}, {}), "('config', '--file', test_condarc, '--add', 'channels', 'test'\n    )", False, 'from tests.helpers import run_conda_command\n'), ((387, 8, 388, 33), 'tests.helpers.run_conda_command', 'run_conda_command', ({(387, 26, 387, 34): '"""config"""', (387, 36, 387, 44): '"""--file"""', (387, 46, 387, 58): 'test_condarc', (387, 60, 387, 67): '"""--set"""', (388, 12, 388, 24): '"""always_yes"""', (388, 26, 388, 32): '"""true"""'}, {}), "('config', '--file', test_condarc, '--set', 'always_yes',\n    'true')", False, 'from tests.helpers import run_conda_command\n'), ((389, 25, 390, 43), 'tests.helpers.run_conda_command', 'run_conda_command', ({(389, 43, 389, 51): '"""config"""', (389, 53, 389, 61): '"""--file"""', (389, 63, 389, 75): 'test_condarc', (390, 12, 390, 22): '"""--remove"""', (390, 24, 390, 34): '"""channels"""', (390, 36, 390, 42): '"""test"""'}, {}), "('config', '--file', test_condarc, '--remove', 'channels',\n    'test')", False, 'from tests.helpers import run_conda_command\n'), ((395, 25, 396, 54), 'tests.helpers.run_conda_command', 'run_conda_command', ({(395, 43, 395, 51): '"""config"""', (395, 53, 395, 61): '"""--file"""', (395, 63, 395, 75): 'test_condarc', (396, 12, 396, 22): '"""--remove"""', (396, 24, 396, 34): '"""channels"""', (396, 36, 396, 42): '"""test"""', (396, 44, 396, 53): '"""--force"""'}, {}), "('config', '--file', test_condarc, '--remove', 'channels',\n    'test', '--force')", False, 'from tests.helpers import run_conda_command\n'), ((400, 25, 401, 56), 'tests.helpers.run_conda_command', 'run_conda_command', ({(400, 43, 400, 51): '"""config"""', (400, 53, 400, 61): '"""--file"""', (400, 63, 400, 75): 'test_condarc', (401, 12, 401, 22): '"""--remove"""', (401, 24, 401, 34): '"""disallow"""', (401, 36, 401, 44): '"""python"""', (401, 46, 401, 55): '"""--force"""'}, {}), "('config', '--file', test_condarc, '--remove', 'disallow',\n    'python', '--force')", False, 'from tests.helpers import run_conda_command\n'), ((405, 25, 406, 52), 'tests.helpers.run_conda_command', 'run_conda_command', ({(405, 43, 405, 51): '"""config"""', (405, 53, 405, 61): '"""--file"""', (405, 63, 405, 75): 'test_condarc', (406, 12, 406, 26): '"""--remove-key"""', (406, 28, 406, 40): '"""always_yes"""', (406, 42, 406, 51): '"""--force"""'}, {}), "('config', '--file', test_condarc, '--remove-key',\n    'always_yes', '--force')", False, 'from tests.helpers import run_conda_command\n'), ((410, 25, 411, 52), 'tests.helpers.run_conda_command', 'run_conda_command', ({(410, 43, 410, 51): '"""config"""', (410, 53, 410, 61): '"""--file"""', (410, 63, 410, 75): 'test_condarc', (411, 12, 411, 26): '"""--remove-key"""', (411, 28, 411, 40): '"""always_yes"""', (411, 42, 411, 51): '"""--force"""'}, {}), "('config', '--file', test_condarc, '--remove-key',\n    'always_yes', '--force')", False, 'from tests.helpers import run_conda_command\n'), ((415, 8, 415, 31), 'os.unlink', 'os.unlink', ({(415, 18, 415, 30): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((429, 25, 430, 34), 'tests.helpers.run_conda_command', 'run_conda_command', ({(429, 43, 429, 51): '"""config"""', (429, 53, 429, 61): '"""--file"""', (429, 63, 429, 75): 'test_condarc', (429, 77, 429, 84): '"""--add"""', (430, 12, 430, 25): '"""notarealkey"""', (430, 27, 430, 33): '"""test"""'}, {}), "('config', '--file', test_condarc, '--add', 'notarealkey',\n    'test')", False, 'from tests.helpers import run_conda_command\n'), ((435, 25, 436, 33), 'tests.helpers.run_conda_command', 'run_conda_command', ({(435, 43, 435, 51): '"""config"""', (435, 53, 435, 61): '"""--file"""', (435, 63, 435, 75): 'test_condarc', (435, 77, 435, 84): '"""--set"""', (436, 12, 436, 25): '"""notarealkey"""', (436, 27, 436, 32): '"""yes"""'}, {}), "('config', '--file', test_condarc, '--set', 'notarealkey',\n    'yes')", False, 'from tests.helpers import run_conda_command\n'), ((459, 25, 460, 71), 'tests.helpers.run_conda_command', 'run_conda_command', ({(459, 43, 459, 51): '"""config"""', (459, 53, 459, 61): '"""--file"""', (459, 63, 459, 75): 'test_condarc', (460, 43, 460, 50): '"""--add"""', (460, 52, 460, 62): '"""channels"""', (460, 64, 460, 70): '"""test"""'}, {}), "('config', '--file', test_condarc, '--add', 'channels', 'test'\n    )", False, 'from tests.helpers import run_conda_command\n'), ((468, 8, 468, 31), 'os.unlink', 'os.unlink', ({(468, 18, 468, 30): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((481, 25, 482, 72), 'tests.helpers.run_conda_command', 'run_conda_command', ({(481, 43, 481, 51): '"""config"""', (481, 53, 481, 61): '"""--file"""', (481, 63, 481, 75): 'test_condarc', (482, 43, 482, 50): '"""--set"""', (482, 52, 482, 64): '"""always_yes"""', (482, 66, 482, 71): '"""yep"""'}, {}), "('config', '--file', test_condarc, '--set', 'always_yes',\n    'yep')", False, 'from tests.helpers import run_conda_command\n'), ((498, 25, 499, 72), 'tests.helpers.run_conda_command', 'run_conda_command', ({(498, 43, 498, 51): '"""config"""', (498, 53, 498, 61): '"""--file"""', (498, 63, 498, 75): 'test_condarc', (499, 43, 499, 50): '"""--set"""', (499, 52, 499, 64): '"""ssl_verify"""', (499, 66, 499, 71): '"""yes"""'}, {}), "('config', '--file', test_condarc, '--set', 'ssl_verify',\n    'yes')", False, 'from tests.helpers import run_conda_command\n'), ((506, 25, 507, 84), 'tests.helpers.run_conda_command', 'run_conda_command', ({(506, 43, 506, 51): '"""config"""', (506, 53, 506, 61): '"""--file"""', (506, 63, 506, 75): 'test_condarc', (507, 43, 507, 50): '"""--set"""', (507, 52, 507, 64): '"""ssl_verify"""', (507, 66, 507, 83): '"""test_string.crt"""'}, {}), "('config', '--file', test_condarc, '--set', 'ssl_verify',\n    'test_string.crt')", False, 'from tests.helpers import run_conda_command\n'), ((515, 8, 515, 31), 'os.unlink', 'os.unlink', ({(515, 18, 515, 30): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((68, 25, 68, 51), 'conda.config.get_proxy_servers', 'config.get_proxy_servers', ({}, {}), '()', True, 'import conda.config as config\n'), ((75, 15, 75, 45), 'conda.config.rc.get', 'config.rc.get', ({(75, 29, 75, 44): '"""channel_alias"""'}, {}), "('channel_alias')", True, 'import conda.config as config\n'), ((77, 32, 79, 24), 'conda.config.normalize_urls', 'config.normalize_urls', ({(77, 54, 79, 23): "['defaults', 'system', 'https://anaconda.org/username',\n    'file:///Users/username/repo', 'username']"}, {}), "(['defaults', 'system',\n    'https://anaconda.org/username', 'file:///Users/username/repo', 'username']\n    )", True, 'import conda.config as config\n'), ((82, 25, 85, 24), 'conda.config.normalize_urls', 'config.normalize_urls', ({(82, 47, 85, 13): "['defaults', 'system', 'https://conda.anaconda.org/username',\n    'file:///Users/username/repo', 'username']", (85, 15, 85, 23): '"""osx-64"""'}, {}), "(['defaults', 'system',\n    'https://conda.anaconda.org/username', 'file:///Users/username/repo',\n    'username'], 'osx-64')", True, 'import conda.config as config\n'), ((114, 19, 114, 49), 'os.path.exists', 'os.path.exists', ({(114, 34, 114, 48): '"""test_condarc"""'}, {}), "('test_condarc')", False, 'import os\n'), ((163, 12, 163, 35), 'os.unlink', 'os.unlink', ({(163, 22, 163, 34): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((261, 12, 261, 35), 'os.unlink', 'os.unlink', ({(261, 22, 261, 34): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((375, 12, 375, 35), 'os.unlink', 'os.unlink', ({(375, 22, 375, 34): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((420, 12, 420, 35), 'os.unlink', 'os.unlink', ({(420, 22, 420, 34): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((433, 19, 433, 39), 'os.path.exists', 'exists', ({(433, 26, 433, 38): 'test_condarc'}, {}), '(test_condarc)', False, 'from os.path import dirname, join, exists\n'), ((439, 19, 439, 39), 'os.path.exists', 'exists', ({(439, 26, 439, 38): 'test_condarc'}, {}), '(test_condarc)', False, 'from os.path import dirname, join, exists\n'), ((444, 12, 444, 35), 'os.unlink', 'os.unlink', ({(444, 22, 444, 34): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((472, 12, 472, 35), 'os.unlink', 'os.unlink', ({(472, 22, 472, 34): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((489, 12, 489, 35), 'os.unlink', 'os.unlink', ({(489, 22, 489, 34): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((518, 12, 518, 35), 'os.unlink', 'os.unlink', ({(518, 22, 518, 34): 'test_condarc'}, {}), '(test_condarc)', False, 'import os\n'), ((61, 13, 61, 35), 'os.path.join', 'join', ({(61, 18, 61, 26): 'root_dir', (61, 28, 61, 34): '"""envs"""'}, {}), "(root_dir, 'envs')", False, 'from os.path import dirname, join, exists\n'), ((65, 29, 65, 62), 'conda.config.pkgs_dir_from_envs_dir', 'config.pkgs_dir_from_envs_dir', ({(65, 59, 65, 61): 'pi'}, {}), '(pi)', True, 'import conda.config as config\n')]