示例#1
0
def test_pseudo_boolean():
    # The latest version of iopro, 1.5.0, was not built against numpy 1.5
    assert r.install(['iopro', 'python 2.7*', 'numpy 1.5*'], returnall=True) == [[
        Dist(add_defaults_if_no_channel(fn)) for fn in [
        'iopro-1.4.3-np15py27_p0.tar.bz2',
        'numpy-1.5.1-py27_4.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'unixodbc-2.3.1-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    ]]]

    assert r.install(['iopro', 'python 2.7*', 'numpy 1.5*', 'mkl@'], returnall=True) == [[
        Dist(add_defaults_if_no_channel(fn)) for fn in [
        'iopro-1.4.3-np15py27_p0.tar.bz2',
        'mkl-rt-11.0-p0.tar.bz2',
        'numpy-1.5.1-py27_p4.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'unixodbc-2.3.1-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    ]]]
示例#2
0
    def test_update_in_private_env_add_remove_action(self, remove_actions):
        required_solves = [
            plan.SpecsForPrefix(prefix="root/prefix/envs/_env_",
                                specs=["test1", "test2"],
                                r=self.res),
            plan.SpecsForPrefix(prefix=context.root_dir,
                                specs=["test3"],
                                r=self.res)
        ]

        action = defaultdict(list)
        action["PREFIX"] = "root/prefix/envs/_env_"
        action["LINK"] = [Dist("test1-2.1.4-1"), Dist("test2-1.1.1-8")]
        actions = [action]

        test_link_data = {context.root_prefix: {Dist("test1-2.1.4-1"): True}}
        with patch("conda.core.linked_data.linked_data_", test_link_data):
            plan.add_unlink_options_for_update(actions, required_solves,
                                               self.res.index)

        expected_output = [
            action,
            generate_remove_action("root/prefix", [Dist("test1-2.1.4-1")])
        ]
        self.assertEquals(actions, expected_output)
示例#3
0
def to_action(specs_to_add, specs_to_remove, prefix, to_link, to_unlink, index):
    to_link_records = []

    prefix_data = PrefixData(prefix)
    final_precs = IndexedSet(prefix_data.iter_records())

    lookup_dict = {}
    for _, c in index:
        lookup_dict[Channel(c).url(with_credentials=False)] = c

    assert len(to_unlink) == 0

    for c, pkg, jsn_s in to_link:
        sdir = lookup_dict[split_anaconda_token(remove_auth(c))[0]]
        rec = to_package_record_from_subjson(sdir, pkg, jsn_s)
        final_precs.add(rec)
        to_link_records.append(rec)

    unlink_precs, link_precs = diff_for_unlink_link_precs(
        prefix,
        final_precs=IndexedSet(PrefixGraph(final_precs).graph),
        specs_to_add=specs_to_add,
    )

    actions = get_blank_actions(prefix)
    actions["UNLINK"].extend(Dist(prec) for prec in unlink_precs)
    actions["LINK"].extend(Dist(prec) for prec in link_precs)
    return actions
示例#4
0
 def test_anaconda_mkl_3(self):
     # to test "with_features_depends"
     dists = r.install(['anaconda 1.5.0', 'python 3*', 'mkl@'])
     self.assert_have_mkl(dists, ('numpy', 'scipy'))
     self.assertTrue(Dist('defaults::scipy-0.12.0-np17py33_p0.tar.bz2') in dists)
     self.assertTrue(Dist('defaults::mkl-rt-11.0-p0.tar.bz2') in dists)
     self.assertEqual(len(dists), 61)
示例#5
0
def test_remove():
    installed = r.install(['pandas', 'python 2.7*'])
    assert installed == [
        Dist(add_defaults_if_no_channel(fname)) for fname in [
            'dateutil-2.1-py27_1.tar.bz2', 'numpy-1.7.1-py27_0.tar.bz2',
            'openssl-1.0.1c-0.tar.bz2', 'pandas-0.11.0-np17py27_1.tar.bz2',
            'python-2.7.5-0.tar.bz2', 'pytz-2013b-py27_0.tar.bz2',
            'readline-6.2-0.tar.bz2', 'scipy-0.12.0-np17py27_0.tar.bz2',
            'six-1.3.0-py27_0.tar.bz2', 'sqlite-3.7.13-0.tar.bz2',
            'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2',
            'zlib-1.2.7-0.tar.bz2'
        ]
    ]

    assert r.remove(['pandas'], installed=installed) == [
        Dist(add_defaults_if_no_channel(fname)) for fname in [
            'dateutil-2.1-py27_1.tar.bz2', 'numpy-1.7.1-py27_0.tar.bz2',
            'openssl-1.0.1c-0.tar.bz2', 'python-2.7.5-0.tar.bz2',
            'pytz-2013b-py27_0.tar.bz2', 'readline-6.2-0.tar.bz2',
            'scipy-0.12.0-np17py27_0.tar.bz2', 'six-1.3.0-py27_0.tar.bz2',
            'sqlite-3.7.13-0.tar.bz2', 'system-5.8-1.tar.bz2',
            'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2'
        ]
    ]

    # Pandas requires numpy
    assert r.remove(['numpy'], installed=installed) == [
        Dist(add_defaults_if_no_channel(fname)) for fname in [
            'dateutil-2.1-py27_1.tar.bz2', 'openssl-1.0.1c-0.tar.bz2',
            'python-2.7.5-0.tar.bz2', 'pytz-2013b-py27_0.tar.bz2',
            'readline-6.2-0.tar.bz2', 'six-1.3.0-py27_0.tar.bz2',
            'sqlite-3.7.13-0.tar.bz2', 'system-5.8-1.tar.bz2',
            'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2'
        ]
    ]
示例#6
0
 def test_explicit2(self):
     self.assertEqual(r.explicit(['pycosat 0.6.0 py27_0',
                                  'zlib 1.2.7 0']),
                      [Dist('defaults::pycosat-0.6.0-py27_0.tar.bz2'),
                       Dist('defaults::zlib-1.2.7-0.tar.bz2')])
     self.assertEqual(r.explicit(['pycosat 0.6.0 py27_0',
                                  'zlib 1.2.7']), None)
示例#7
0
def test_broken_install():
    installed = r.install(['pandas', 'python 2.7*', 'numpy 1.6*'])
    assert installed == [Dist(add_defaults_if_no_channel(fname)) for fname in [
        'dateutil-2.1-py27_1.tar.bz2',
        'numpy-1.6.2-py27_4.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'pandas-0.11.0-np16py27_1.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'pytz-2013b-py27_0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'scipy-0.12.0-np16py27_0.tar.bz2',
        'six-1.3.0-py27_0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2']]

    # Add an incompatible numpy; installation should be untouched
    installed1 = list(installed)
    installed1[1] = Dist('defaults::numpy-1.7.1-py33_p0.tar.bz2')
    assert set(r.install([], installed1)) == set(installed1)
    assert r.install(['numpy 1.6*'], installed1) == installed

    # Add an incompatible pandas; installation should be untouched, then fixed
    installed2 = list(installed)
    installed2[3] = Dist('defaults::pandas-0.11.0-np17py27_1.tar.bz2')
    assert set(r.install([], installed2)) == set(installed2)
    assert r.install(['pandas'], installed2) == installed

    # Removing pandas should fix numpy, since pandas depends on it
    installed3 = list(installed)
    installed3[1] = Dist('defaults::numpy-1.7.1-py33_p0.tar.bz2')
    installed3[3] = Dist('defaults::pandas-0.11.0-np17py27_1.tar.bz2')
    installed4 = r.remove(['pandas'], installed)
    assert r.bad_installed(installed4, [])[0] is None
示例#8
0
def test_channel_priority():
    fn1 = 'pandas-0.10.1-np17py27_0.tar.bz2'
    fn2 = 'other::' + fn1
    spec = ['pandas', 'python 2.7*']
    index2 = index.copy()
    index2[Dist(fn2)] = index2[Dist(add_defaults_if_no_channel(fn1))].copy()
    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r2 = Resolve(index2)
    rec = r2.index[Dist(fn2)]

    os.environ['CONDA_CHANNEL_PRIORITY'] = 'True'
    reset_context(())

    r2.index[Dist(fn2)] = IndexRecord.from_objects(r2.index[Dist(fn2)], priority=0)
    # Should select the "other", older package because it
    # has a lower channel priority number
    installed1 = r2.install(spec)
    # Should select the newer package because now the "other"
    # package has a higher priority number
    r2.index[Dist(fn2)] = IndexRecord.from_objects(r2.index[Dist(fn2)], priority=2)
    installed2 = r2.install(spec)
    # Should also select the newer package because we have
    # turned off channel priority altogether

    os.environ['CONDA_CHANNEL_PRIORITY'] = 'False'
    reset_context(())

    r2.index[Dist(fn2)] = IndexRecord.from_objects(r2.index[Dist(fn2)], priority=0)
    installed3 = r2.install(spec)
    assert installed1 != installed2
    assert installed1 != installed3
    assert installed2 == installed3
示例#9
0
def to_action(specs_to_add, specs_to_remove, prefix, to_link, to_unlink,
              index):
    to_link_records, to_unlink_records = [], []

    prefix_data = PrefixData(prefix)
    final_precs = IndexedSet(prefix_data.iter_records())

    lookup_dict = {}
    for _, c in index:
        lookup_dict[str(c)] = c

    for c, pkg in to_unlink:
        for i_rec in installed_pkg_recs:
            if i_rec.fn == pkg:
                final_precs.remove(i_rec)
                to_unlink_records.append(i_rec)
                break
        else:
            print("No package record found!")

    for c, pkg, jsn_s in to_link:
        sdir = lookup_dict[c]
        rec = to_package_record_from_subjson(sdir, pkg, jsn_s)
        final_precs.add(rec)
        to_link_records.append(rec)

    unlink_precs, link_precs = diff_for_unlink_link_precs(
        prefix,
        final_precs=IndexedSet(PrefixGraph(final_precs).graph),
        specs_to_add=specs_to_add)

    actions = get_blank_actions(prefix)
    actions['UNLINK'].extend(Dist(prec) for prec in unlink_precs)
    actions['LINK'].extend(Dist(prec) for prec in link_precs)
    return actions
示例#10
0
def test_update_deps():
    installed = r.install(['python 2.7*', 'numpy 1.6*', 'pandas 0.10.1'])
    assert installed == [
        Dist(add_defaults_if_no_channel(fn)) for fn in [
            'dateutil-2.1-py27_1.tar.bz2',
            'numpy-1.6.2-py27_4.tar.bz2',
            'openssl-1.0.1c-0.tar.bz2',
            'pandas-0.10.1-np16py27_0.tar.bz2',
            'python-2.7.5-0.tar.bz2',
            'readline-6.2-0.tar.bz2',
            'scipy-0.11.0-np16py27_3.tar.bz2',
            'six-1.3.0-py27_0.tar.bz2',
            'sqlite-3.7.13-0.tar.bz2',
            'system-5.8-1.tar.bz2',
            'tk-8.5.13-0.tar.bz2',
            'zlib-1.2.7-0.tar.bz2',
        ]
    ]

    # scipy, and pandas should all be updated here. pytz is a new
    # dependency of pandas. But numpy does not _need_ to be updated
    # to get the latest version of pandas, so it stays put.
    assert r.install(
        ['pandas', 'python 2.7*'],
        installed=installed,
        update_deps=True,
        returnall=True) == [[
            Dist(add_defaults_if_no_channel(fn)) for fn in [
                'dateutil-2.1-py27_1.tar.bz2', 'numpy-1.6.2-py27_4.tar.bz2',
                'openssl-1.0.1c-0.tar.bz2', 'pandas-0.11.0-np16py27_1.tar.bz2',
                'python-2.7.5-0.tar.bz2', 'pytz-2013b-py27_0.tar.bz2',
                'readline-6.2-0.tar.bz2', 'scipy-0.12.0-np16py27_0.tar.bz2',
                'six-1.3.0-py27_0.tar.bz2', 'sqlite-3.7.13-0.tar.bz2',
                'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2',
                'zlib-1.2.7-0.tar.bz2'
            ]
        ]]

    # pandas should be updated here. However, it's going to try to not update
    # scipy, so it won't be updated to the latest version (0.11.0).
    assert r.install(['pandas', 'python 2.7*'],
                     installed=installed,
                     update_deps=False,
                     returnall=True) == [[
                         Dist(add_defaults_if_no_channel(fn)) for fn in [
                             'dateutil-2.1-py27_1.tar.bz2',
                             'numpy-1.6.2-py27_4.tar.bz2',
                             'openssl-1.0.1c-0.tar.bz2',
                             'pandas-0.10.1-np16py27_0.tar.bz2',
                             'python-2.7.5-0.tar.bz2',
                             'readline-6.2-0.tar.bz2',
                             'scipy-0.11.0-np16py27_3.tar.bz2',
                             'six-1.3.0-py27_0.tar.bz2',
                             'sqlite-3.7.13-0.tar.bz2',
                             'system-5.8-1.tar.bz2',
                             'tk-8.5.13-0.tar.bz2',
                             'zlib-1.2.7-0.tar.bz2',
                         ]
                     ]]
示例#11
0
    def test_channel(self):
        d = Dist.from_string("conda-forge::spyder-app-2.3.8-py27_0.tar.bz2")
        assert d.channel == 'conda-forge'
        assert d.quad[0] == "spyder-app"
        assert d.dist_name == "spyder-app-2.3.8-py27_0"

        d = Dist.from_string("s3://some/bucket/name::spyder-app-2.3.8-py27_0.tar.bz2")
        assert d.channel == 's3://some/bucket/name'
        assert d.quad[0] == "spyder-app"
        assert d.dist_name == "spyder-app-2.3.8-py27_0"
示例#12
0
def DPkg(s, **kwargs):
    d = Dist(s)
    return IndexRecord(
        fn=d.to_filename(),
        name=d.name,
        version=d.version,
        build=d.build_string,
        build_number=int(d.build_string.rsplit('_', 1)[-1]),
        schannel=d.channel,
        **kwargs)
示例#13
0
    def test_dist_with_channel_url(self):
        # standard named channel
        url = "https://repo.continuum.io/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2"
        d = Dist(url)
        assert d.channel == 'defaults'
        assert d.name == 'spyder-app'
        assert d.version == '2.3.8'
        assert d.build_string == 'py27_0'

        assert d.to_url() == url
        assert d.is_channel is True

        # standard url channel
        url = "https://not.real.continuum.io/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2"
        d = Dist(url)
        assert d.channel == 'defaults'  # because pkgs/free is in defaults
        assert d.name == 'spyder-app'
        assert d.version == '2.3.8'
        assert d.build_string == 'py27_0'

        assert d.to_url() == url
        assert d.is_channel is True

        # another standard url channel
        url = "https://not.real.continuum.io/not/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2"
        d = Dist(url)
        assert d.channel == 'https://not.real.continuum.io/not/free'
        assert d.name == 'spyder-app'
        assert d.version == '2.3.8'
        assert d.build_string == 'py27_0'

        assert d.to_url() == url
        assert d.is_channel is True

        # local file url that is a named channel
        url = path_to_url(join_url(context.croot, 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2'))
        d = Dist(url)
        assert d.channel == 'local'
        assert d.name == 'bcrypt'
        assert d.version == '3.1.1'
        assert d.build_string == 'py35_2'

        assert d.to_url() == url
        assert d.is_channel is True

        # local file url that is not a named channel
        url = join_url('file:///some/location/on/disk', 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2')
        d = Dist(url)
        assert d.channel == 'file:///some/location/on/disk'
        assert d.name == 'bcrypt'
        assert d.version == '3.1.1'
        assert d.build_string == 'py35_2'

        assert d.to_url() == url
        assert d.is_channel is True
示例#14
0
    def test_dist_with_non_channel_url(self):
        # contrived url
        url = "https://repo.anaconda.com/pkgs/anaconda/cffi-1.9.1-py34_0.tar.bz2"
        d = Dist(url)
        assert d.channel == '<unknown>'
        assert d.name == 'cffi'
        assert d.version == '1.9.1'
        assert d.build_string == 'py34_0'

        assert d.to_url() == url
        assert d.is_channel is False

        # file url that is not a channel
        url = path_to_url(join_url(context.croot, 'cffi-1.9.1-py34_0.tar.bz2'))
        d = Dist(url)
        assert d.channel == '<unknown>'
        assert d.name == 'cffi'
        assert d.version == '1.9.1'
        assert d.build_string == 'py34_0'

        assert d.to_url() == url
        assert d.is_channel is False

        # file url that is a package cache
        # TODO: maybe this should look up the channel in urls.txt?  or maybe that's too coupled?
        url = join_url(path_to_url(context.pkgs_dirs[0]),
                       'cffi-1.9.1-py34_0.tar.bz2')
        d = Dist(url)
        assert d.channel == '<unknown>'
        assert d.name == 'cffi'
        assert d.version == '1.9.1'
        assert d.build_string == 'py34_0'

        assert d.to_url() == url
        assert d.is_channel is False
示例#15
0
 def test1(self):
     installed = r.install(
         ['anaconda 1.5.0', 'python 2.7*', 'numpy 1.7*', 'mkl@'])
     for old, new in [('numpy-1.7.1-py27_p0.tar.bz2',
                       'numpy-1.7.1-py27_0.tar.bz2'),
                      ('scipy-0.12.0-np17py27_p0.tar.bz2',
                       'scipy-0.12.0-np17py27_0.tar.bz2'),
                      ('mkl-rt-11.0-p0.tar.bz2', None)]:
         assert Dist(old) in installed
         assert r.find_substitute(installed, f_mkl,
                                  old) == (Dist(new) if new else None)
示例#16
0
    def test_with_feature_depends(self):
        d = Dist.from_string("spyder-app-2.3.8-py27_0[mkl]")
        assert d.with_features_depends == "mkl"

        d = Dist("mkl@")
        assert d.channel == "@"
        assert d.quad[0] == "mkl@"
        assert d.quad[1] == ""
        assert d.quad[2] == ""
        assert d.with_features_depends is None
        assert d.is_feature_package
示例#17
0
    def test_channel(self):
        d = Dist.from_string("conda-forge::spyder-app-2.3.8-py27_0.tar.bz2")
        assert d.channel == 'conda-forge'
        assert d.quad[0] == "spyder-app"
        assert d.dist_name == "spyder-app-2.3.8-py27_0"

        d = Dist.from_string(
            "s3://some/bucket/name::spyder-app-2.3.8-py27_0.tar.bz2")
        assert d.channel == 's3://some/bucket/name'
        assert d.quad[0] == "spyder-app"
        assert d.dist_name == "spyder-app-2.3.8-py27_0"
示例#18
0
def DPkg(s, **kwargs):
    d = Dist(s)
    return PackageRecord(fn=d.to_filename(),
                         name=d.name,
                         version=d.version,
                         build=d.build_string,
                         build_number=int(d.build_string.rsplit('_', 1)[-1]),
                         channel=d.channel,
                         subdir=context.subdir,
                         md5="012345789",
                         **kwargs)
示例#19
0
    def test_anaconda_mkl_2(self):
        # to test "with_features_depends"
        dists = r.install(['anaconda 1.5.0', 'python 2.7*', 'numpy 1.7*', 'mkl@'])
        self.assert_have_mkl(dists, ('numpy', 'scipy', 'numexpr', 'scikit-learn'))
        self.assertTrue(Dist('defaults::scipy-0.12.0-np17py27_p0.tar.bz2') in dists)
        self.assertTrue(Dist('defaults::mkl-rt-11.0-p0.tar.bz2') in dists)
        self.assertEqual(len(dists), 108)

        dists2 = r.install(['anaconda 1.5.0', 'python 2.7*', 'numpy 1.7*', 'mkl'])
        self.assertTrue(set(dists) <= set(dists2))
        self.assertEqual(len(dists2), 110)
示例#20
0
    def test_update_in_root_env(self, prefix_if_in_private_env):
        required_solves = [plan.SpecsForPrefix(prefix=context.root_dir, specs=["test3", "test4"],
                                               r=self.res)]

        action = defaultdict(list)
        action["PREFIX"] = "root/prefix"
        action["LINK"] = [Dist("test3-1.2.0"), Dist("test4-1.2.1")]
        actions = [action]
        plan.add_unlink_options_for_update(actions, required_solves, self.res.index)
        expected_output = [action, generate_remove_action(
            "some/prefix/envs/_env_", [Dist("test3-1.2.0"), Dist("test4-2.1.0-22")])]
        self.assertEquals(actions, expected_output)
示例#21
0
    def test_ensure_linked_actions_all_linked(self, load_meta):
        dists = [Dist("test-88"), Dist("test-spec-42"), Dist("test-spec2-8.0.0.0.1-9")]
        prefix = "some/prefix"

        link_actions = plan.ensure_linked_actions(dists, prefix)

        expected_output = defaultdict(list)
        expected_output["PREFIX"] = prefix
        expected_output["op_order"] = ('CHECK_FETCH', 'RM_FETCHED', 'FETCH', 'CHECK_EXTRACT',
                                       'RM_EXTRACTED', 'EXTRACT', 'UNLINK', 'LINK',
                                       'SYMLINK_CONDA')
        self.assertEquals(link_actions, expected_output)
示例#22
0
def DPkg(s, **kwargs):
    d = Dist(s)
    return PackageRecord(
        fn=d.to_filename(),
        name=d.name,
        version=d.version,
        build=d.build_string,
        build_number=int(d.build_string.rsplit('_', 1)[-1]),
        channel=d.channel,
        subdir=context.subdir,
        md5="012345789",
        **kwargs)
示例#23
0
def test_channel(fmt):
    d = Dist.from_string("conda-forge::spyder-app-2.3.8-py27_0{}".format(fmt))
    assert d.channel == 'conda-forge'
    assert d.quad[0] == "spyder-app"
    assert d.dist_name == "spyder-app-2.3.8-py27_0"
    assert d.fmt == fmt

    d = Dist.from_string("s3://some/bucket/name::spyder-app-2.3.8-py27_0{}".format(fmt))
    assert d.channel == 's3://some/bucket/name'
    assert d.quad[0] == "spyder-app"
    assert d.dist_name == "spyder-app-2.3.8-py27_0"
    assert d.to_url() == join_url("s3://some/bucket/name", context.subdir,
                                    "spyder-app-2.3.8-py27_0{}".format(fmt))
示例#24
0
def test_multiple_solution():
    index2 = index.copy()
    fn = 'pandas-0.11.0-np16py27_1.tar.bz2'
    res1 = set([fn])
    for k in range(1,15):
        fn2 = Dist('%s_%d.tar.bz2'%(fn[:-8],k))
        index2[fn2] = index[Dist(add_defaults_if_no_channel(fn))]
        res1.add(fn2)
    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r = Resolve(index2)
    res = r.solve(['pandas', 'python 2.7*', 'numpy 1.6*'], returnall=True)
    res = set([y for x in res for y in x if r.package_name(y).startswith('pandas')])
    assert len(res) <= len(res1)
示例#25
0
    def test_match(self):
        for spec, res in [
            ('numpy 1.7*', True),          ('numpy 1.7.1', True),
            ('numpy 1.7', False),          ('numpy 1.5*', False),
            ('numpy >=1.5', True),         ('numpy >=1.5,<2', True),
            ('numpy >=1.8,<1.9', False),   ('numpy >1.5,<2,!=1.7.1', False),
            ('numpy >1.8,<2|==1.7', False),('numpy >1.8,<2|>=1.7.1', True),
            ('numpy >=1.8|1.7*', True),    ('numpy ==1.7', False),
            ('numpy >=1.5,>1.6', True),    ('numpy ==1.7.1', True),
            ('numpy >=1,*.7.*', True),     ('numpy *.7.*,>=1', True),
            ('numpy >=1,*.8.*', False),    ('numpy >=2,*.7.*', False),
            ('numpy 1.6*|1.7*', True),     ('numpy 1.6*|1.8*', False),
            ('numpy 1.6.2|1.7*', True),    ('numpy 1.6.2|1.7.1', True),
            ('numpy 1.6.2|1.7.0', False),  ('numpy 1.7.1 py27_0', True),
            ('numpy 1.7.1 py26_0', False), ('numpy >1.7.1a', True),
            ('python', False),
            ]:
            m = MatchSpec(spec)
            self.assertEqual(m.match(Dist('numpy-1.7.1-py27_0.tar.bz2')), res)

        # both version numbers conforming to PEP 440
        self.assertFalse(MatchSpec('numpy >=1.0.1').match(Dist('numpy-1.0.1a-0.tar.bz2')))
        # both version numbers non-conforming to PEP 440
        self.assertFalse(MatchSpec('numpy >=1.0.1.vc11').match(Dist('numpy-1.0.1a.vc11-0.tar.bz2')))
        self.assertTrue(MatchSpec('numpy >=1.0.1*.vc11').match(Dist('numpy-1.0.1a.vc11-0.tar.bz2')))
        # one conforming, other non-conforming to PEP 440
        self.assertTrue(MatchSpec('numpy <1.0.1').match(Dist('numpy-1.0.1.vc11-0.tar.bz2')))
        self.assertTrue(MatchSpec('numpy <1.0.1').match(Dist('numpy-1.0.1a.vc11-0.tar.bz2')))
        self.assertFalse(MatchSpec('numpy >=1.0.1.vc11').match(Dist('numpy-1.0.1a-0.tar.bz2')))
        self.assertTrue(MatchSpec('numpy >=1.0.1a').match(Dist('numpy-1.0.1z-0.tar.bz2')))
        self.assertTrue(MatchSpec('numpy >=1.0.1a py27*').match(Dist('numpy-1.0.1z-py27_1.tar.bz2')))
        self.assertTrue(MatchSpec('blas * openblas').match(Dist('blas-1.0-openblas.tar.bz2')))

        self.assertTrue(MatchSpec('blas').is_simple())
        self.assertFalse(MatchSpec('blas').is_exact())
        self.assertFalse(MatchSpec('blas 1.0').is_simple())
        self.assertFalse(MatchSpec('blas 1.0').is_exact())
        self.assertFalse(MatchSpec('blas 1.0 1').is_simple())
        self.assertTrue(MatchSpec('blas 1.0 1').is_exact())
        self.assertFalse(MatchSpec('blas 1.0 *').is_exact())

        m = MatchSpec('blas 1.0', optional=True)
        m2 = MatchSpec(m, optional=False)
        m3 = MatchSpec(m2, target='blas-1.0-0.tar.bz2')
        m4 = MatchSpec(m3, target=None, optional=True)
        self.assertTrue(m.spec == m2.spec and m.optional != m2.optional)
        self.assertTrue(m2.spec == m3.spec and m2.optional == m3.optional and m2.target != m3.target)
        self.assertTrue(m == m4)

        self.assertRaises(ValueError, MatchSpec, 'blas (optional')
        self.assertRaises(ValueError, MatchSpec, 'blas (optional,test)')
示例#26
0
def DPkg(s, **kwargs):
    d = Dist(s)
    _kwargs = dict(
        fn=d.to_filename(),
        name=d.name,
        version=d.version,
        build=d.build_string,
        build_number=int(d.build_string.rsplit('_', 1)[-1]),
        channel=d.channel,
        subdir=context.subdir,
        md5="012345789",
    )
    _kwargs.update(kwargs)
    return IndexRecord(**_kwargs)
示例#27
0
 def setUp(self):
     self.index = {
         Dist.from_string("test1-1", channel_override="defaults"):
             generate_mocked_package(None, "test1", "default", "1.0.1"),
         Dist.from_string("test1-1", channel_override="rando_chnl"):
             generate_mocked_package("env", "test1", "default", "2.1.4"),
         Dist.from_string("test2-2", channel_override="defaults"):
             generate_mocked_package("env", "test2", "default", "1.1.1"),
         Dist.from_string("test3-3", channel_override="defaults"):
             generate_mocked_package(None, "test3", "default", "1.2.0"),
         Dist.from_string("test4-4", channel_override="defaults"):
             generate_mocked_package(None, "test4", "default", "1.2.1")
     }
     self.res = generate_mocked_resolve(None, self.index)
示例#28
0
def test_package_ordering():
    sympy_071 = Package('sympy-0.7.1-py27_0.tar.bz2',
                        r.index[Dist('sympy-0.7.1-py27_0.tar.bz2')])
    sympy_072 = Package('sympy-0.7.2-py27_0.tar.bz2',
                        r.index[Dist('sympy-0.7.2-py27_0.tar.bz2')])
    python_275 = Package('python-2.7.5-0.tar.bz2',
                         r.index[Dist('python-2.7.5-0.tar.bz2')])
    numpy = Package('numpy-1.7.1-py27_0.tar.bz2',
                    r.index[Dist('numpy-1.7.1-py27_0.tar.bz2')])
    numpy_mkl = Package('numpy-1.7.1-py27_p0.tar.bz2',
                        r.index[Dist('numpy-1.7.1-py27_p0.tar.bz2')])

    assert sympy_071 < sympy_072
    assert not sympy_071 < sympy_071
    assert not sympy_072 < sympy_071
    raises(TypeError, lambda: sympy_071 < python_275)

    assert sympy_071 <= sympy_072
    assert sympy_071 <= sympy_071
    assert not sympy_072 <= sympy_071
    assert raises(TypeError, lambda: sympy_071 <= python_275)

    assert sympy_071 == sympy_071
    assert not sympy_071 == sympy_072
    assert (sympy_071 == python_275) is False
    assert (sympy_071 == 1) is False

    assert not sympy_071 != sympy_071
    assert sympy_071 != sympy_072
    assert (sympy_071 != python_275) is True

    assert not sympy_071 > sympy_072
    assert not sympy_071 > sympy_071
    assert sympy_072 > sympy_071
    raises(TypeError, lambda: sympy_071 > python_275)

    assert not sympy_071 >= sympy_072
    assert sympy_071 >= sympy_071
    assert sympy_072 >= sympy_071
    assert raises(TypeError, lambda: sympy_071 >= python_275)

    # The first four are a bit arbitrary. For now, we just test that it
    # doesn't prefer the mkl version.
    assert not numpy > numpy_mkl
    assert not numpy >= numpy_mkl
    assert numpy < numpy_mkl
    assert numpy <= numpy_mkl
    assert (numpy != numpy_mkl) is True
    assert (numpy == numpy_mkl) is False
示例#29
0
 def test_index_record(self):
     dst = Dist('defaults::foo-1.2.3-4.tar.bz2')
     rec = DPkg(dst)
     a = MatchSpec(dst)
     b = MatchSpec(rec)
     assert b.match(rec)
     assert a.match(rec)
示例#30
0
 def test_simply_adds_unlink_on_non_windows(self):
     actions = {}
     dist = Dist.from_string(self.generate_random_dist())
     with self.mock_platform(windows=False):
         plan.add_unlink(actions, dist)
     self.assertIn(inst.UNLINK, actions)
     self.assertEqual(actions[inst.UNLINK], [dist, ])
示例#31
0
def test_install_package_with_feature():
    index2 = index.copy()
    index2['mypackage-1.0-featurepy33_0.tar.bz2'] = IndexRecord(
        **{
            'build': 'featurepy33_0',
            'build_number': 0,
            'depends': ['python 3.3*'],
            'name': 'mypackage',
            'version': '1.0',
            'features': 'feature',
        })
    index2['feature-1.0-py33_0.tar.bz2'] = IndexRecord(
        **{
            'build': 'py33_0',
            'build_number': 0,
            'depends': ['python 3.3*'],
            'name': 'feature',
            'version': '1.0',
            'track_features': 'feature',
        })

    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r = Resolve(index2)

    # It should not raise
    r.install(['mypackage', 'feature 1.0'])
示例#32
0
 def test_explicit1(self):
     self.assertEqual(r.explicit(['pycosat 0.6.0 py27_0']), None)
     self.assertEqual(r.explicit(['zlib']), None)
     self.assertEqual(r.explicit(['zlib 1.2.7']), None)
     # because zlib has no dependencies it is also explicit
     exp_result = r.explicit([MatchSpec('zlib 1.2.7 0', schannel='defaults')])
     self.assertEqual(exp_result, [Dist('defaults::zlib-1.2.7-0.tar.bz2')])
示例#33
0
 def test_explicit1(self):
     self.assertEqual(r.explicit(['pycosat 0.6.0 py27_0']), None)
     self.assertEqual(r.explicit(['zlib']), None)
     self.assertEqual(r.explicit(['zlib 1.2.7']), None)
     # because zlib has no dependencies it is also explicit
     self.assertEqual(r.explicit(['zlib 1.2.7 0']),
                      [Dist('zlib-1.2.7-0.tar.bz2')])
示例#34
0
 def test_llvm(self):
     ms = MatchSpec('llvm')
     pkgs = [Package(fn, r.index[Dist(fn)]) for fn in r.find_matches(ms)]
     pkgs.sort()
     self.assertEqual(
         [p.fn for p in pkgs],
         ['llvm-3.1-0.tar.bz2', 'llvm-3.1-1.tar.bz2', 'llvm-3.2-0.tar.bz2'])
示例#35
0
def test_install_package_with_feature():
    index2 = index.copy()
    index2['mypackage-1.0-featurepy33_0.tar.bz2'] = IndexRecord(
        **{
            "channel": "defaults",
            "subdir": context.subdir,
            "md5": "0123456789",
            "fn": "doesnt-matter-here",
            'build': 'featurepy33_0',
            'build_number': 0,
            'depends': ['python 3.3*'],
            'name': 'mypackage',
            'version': '1.0',
            'features': 'feature',
        })
    index2['feature-1.0-py33_0.tar.bz2'] = IndexRecord(
        **{
            "channel": "defaults",
            "subdir": context.subdir,
            "md5": "0123456789",
            "fn": "doesnt-matter-here",
            'build': 'py33_0',
            'build_number': 0,
            'depends': ['python 3.3*'],
            'name': 'feature',
            'version': '1.0',
            'track_features': 'feature',
        })

    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r = Resolve(index2)

    # It should not raise
    r.install(['mypackage', 'feature 1.0'])
示例#36
0
    def test_dist(self):
        d = Dist.from_string("spyder-app-2.3.8-py27_0.tar.bz2")
        assert d.channel == UNKNOWN_CHANNEL
        assert d.quad[0] == "spyder-app"
        assert d.quad[1] == "2.3.8"
        assert d.quad[2] == "py27_0"
        assert d.build_number == 0
        assert d.dist_name == "spyder-app-2.3.8-py27_0"

        assert d == Dist.from_string("spyder-app-2.3.8-py27_0")
        assert d != Dist.from_string("spyder-app-2.3.8-py27_1.tar.bz2")

        d2 = Dist("spyder-app-2.3.8-py27_0.tar.bz2")
        assert d == d2

        d3 = Dist(d2)
        assert d3 is d2
示例#37
0
 def setUp(self):
     pkgs = {
         "test-spec": [generate_mocked_package("test1", "test-spec", "defaults", "1"),
                       generate_mocked_package(None, "test-spec", "defaults", "3"),
                       generate_mocked_package(None, "test-spec", "defaults", "2"),
                       generate_mocked_package("ranenv", "test-spec", "rando_chnl", "5")],
         "test-spec2": [generate_mocked_package(None, "test-spec2", "defaults", "1")],
         "no-exist": [generate_mocked_package(None, "no-exist", "nope", "1")]
     }
     index = {
         Dist.from_string("test-spec", channel_override="defaults"):
             generate_mocked_package(None, "test-spec", "default", "1"),
         Dist.from_string("test-spec", channel_override="rando_chnl"):
             generate_mocked_package("ranenv", "test-spec", "default", "5"),
         Dist.from_string("test-spec2", channel_override="defaults"):
             generate_mocked_package("test1", "test-spec2", "default", "1")
     }
     self.res = generate_mocked_resolve(pkgs, index)
     self.specs = [MatchSpec("test-spec"), MatchSpec("test-spec2")]
示例#38
0
    def test_with_feature_depends(self):
        d = Dist.from_string("spyder-app-2.3.8-py27_0[mkl]")
        assert d.with_features_depends == "mkl"

        d = Dist("mkl@")
        assert d.channel == "@"
        assert d.quad[0] == "mkl@"
        assert d.quad[1] == ""
        assert d.quad[2] == ""
        assert d.with_features_depends is None
        assert d.is_feature_package
示例#39
0
    def test_dist_with_non_channel_url(self):
        # contrived url
        url = "https://repo.anaconda.com/pkgs/anaconda/cffi-1.9.1-py34_0.tar.bz2"
        d = Dist(url)
        assert d.channel == '<unknown>'
        assert d.name == 'cffi'
        assert d.version == '1.9.1'
        assert d.build_string == 'py34_0'

        assert d.to_url() == url
        assert d.is_channel is False

        # file url that is not a channel
        url = path_to_url(join_url(context.croot, 'cffi-1.9.1-py34_0.tar.bz2'))
        d = Dist(url)
        assert d.channel == '<unknown>'
        assert d.name == 'cffi'
        assert d.version == '1.9.1'
        assert d.build_string == 'py34_0'

        assert d.to_url() == url
        assert d.is_channel is False

        # file url that is a package cache
        # TODO: maybe this should look up the channel in urls.txt?  or maybe that's too coupled?
        url = join_url(path_to_url(context.pkgs_dirs[0]), 'cffi-1.9.1-py34_0.tar.bz2')
        d = Dist(url)
        assert d.channel == '<unknown>'
        assert d.name == 'cffi'
        assert d.version == '1.9.1'
        assert d.build_string == 'py34_0'

        assert d.to_url() == url
        assert d.is_channel is False
示例#40
0
文件: test_plan.py 项目: ESSS/conda
def generate_mocked_resolve(pkgs, install=None):
    mock_package = namedtuple("IndexRecord",
                              ["preferred_env", "name", "schannel", "version", "fn"])
    mock_resolve = namedtuple("Resolve", ["get_dists_for_spec", "index", "explicit", "install",
                                          "package_name", "dependency_sort"])

    index = {}
    groups = defaultdict(list)
    for preferred_env, name, schannel, version in pkgs:
        dist = Dist.from_string('%s-%s-0' % (name, version), channel_override=schannel)
        pkg = mock_package(preferred_env=preferred_env, name=name, schannel=schannel,
                           version=version, fn=name)
        groups[name].append(dist)
        index[dist] = pkg

    def get_dists_for_spec(spec, emptyok=False):
        # Here, spec should be a MatchSpec
        res = groups[spec.name]
        if not res and not emptyok:
            raise NoPackagesFoundError([(spec,)])
        return res

    def get_explicit(spec):
        return True

    def get_install(spec, installed, update_deps=None):
        return install

    def get_package_name(dist):
        return dist.name

    def get_dependency_sort(specs):
        return tuple(spec for spec in specs.values())

    return mock_resolve(get_dists_for_spec=get_dists_for_spec, index=index, explicit=get_explicit,
                        install=get_install, package_name=get_package_name,
                        dependency_sort=get_dependency_sort)
示例#41
0
 def test_adds_to_existing_actions(self):
     actions = {inst.UNLINK: [{"foo": "bar"}]}
     dist = Dist.from_string(self.generate_random_dist())
     with self.mock_platform(windows=False):
         plan.add_unlink(actions, dist)
     self.assertEqual(2, len(actions[inst.UNLINK]))
示例#42
0
def test_display_actions():
    os.environ["CONDA_SHOW_CHANNEL_URLS"] = "False"
    reset_context(())
    actions = defaultdict(list, {"FETCH": [Dist("sympy-0.7.2-py27_0"), Dist("numpy-1.7.1-py27_0")]})
    # The older test index doesn't have the size metadata
    index[Dist.from_string("sympy-0.7.2-py27_0.tar.bz2")]["size"] = 4374752
    index[Dist.from_string("numpy-1.7.1-py27_0.tar.bz2")]["size"] = 5994338

    with captured() as c:
        display_actions(actions, index)

    assert (
        c.stdout
        == """
The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    sympy-0.7.2                |           py27_0         4.2 MB
    numpy-1.7.1                |           py27_0         5.7 MB
    ------------------------------------------------------------
                                           Total:         9.9 MB

"""
    )

    actions = defaultdict(
        list,
        {
            "PREFIX": "/Users/aaronmeurer/anaconda/envs/test",
            "SYMLINK_CONDA": ["/Users/aaronmeurer/anaconda"],
            "LINK": ["python-3.3.2-0", "readline-6.2-0 1", "sqlite-3.7.13-0 1", "tk-8.5.13-0 1", "zlib-1.2.7-0 1"],
        },
    )

    with captured() as c:
        display_actions(actions, index)

    assert (
        c.stdout
        == """
The following NEW packages will be INSTALLED:

    python:   3.3.2-0 \n\
    readline: 6.2-0   \n\
    sqlite:   3.7.13-0
    tk:       8.5.13-0
    zlib:     1.2.7-0 \n\

"""
    )

    actions["UNLINK"] = actions["LINK"]
    actions["LINK"] = []

    with captured() as c:
        display_actions(actions, index)

    assert (
        c.stdout
        == """
The following packages will be REMOVED:

    python:   3.3.2-0 \n\
    readline: 6.2-0   \n\
    sqlite:   3.7.13-0
    tk:       8.5.13-0
    zlib:     1.2.7-0 \n\

"""
    )

    actions = defaultdict(list, {"LINK": ["cython-0.19.1-py33_0"], "UNLINK": ["cython-0.19-py33_0"]})

    with captured() as c:
        display_actions(actions, index)

    assert (
        c.stdout
        == """
The following packages will be UPDATED:

    cython: 0.19-py33_0 --> 0.19.1-py33_0

"""
    )

    actions["LINK"], actions["UNLINK"] = actions["UNLINK"], actions["LINK"]

    with captured() as c:
        display_actions(actions, index)

    assert (
        c.stdout
        == """
The following packages will be DOWNGRADED due to dependency conflicts:

    cython: 0.19.1-py33_0 --> 0.19-py33_0

"""
    )

    actions = defaultdict(
        list,
        {
            "LINK": ["cython-0.19.1-py33_0", "dateutil-1.5-py33_0", "numpy-1.7.1-py33_0"],
            "UNLINK": ["cython-0.19-py33_0", "dateutil-2.1-py33_1", "pip-1.3.1-py33_1"],
        },
    )

    with captured() as c:
        display_actions(actions, index)

    assert (
        c.stdout
        == """
The following NEW packages will be INSTALLED:

    numpy:    1.7.1-py33_0

The following packages will be REMOVED:

    pip:      1.3.1-py33_1

The following packages will be UPDATED:

    cython:   0.19-py33_0  --> 0.19.1-py33_0

The following packages will be DOWNGRADED due to dependency conflicts:

    dateutil: 2.1-py33_1   --> 1.5-py33_0   \n\

"""
    )

    actions = defaultdict(
        list,
        {
            "LINK": ["cython-0.19.1-py33_0", "dateutil-2.1-py33_1"],
            "UNLINK": ["cython-0.19-py33_0", "dateutil-1.5-py33_0"],
        },
    )

    with captured() as c:
        display_actions(actions, index)

    assert (
        c.stdout
        == """
The following packages will be UPDATED:

    cython:   0.19-py33_0 --> 0.19.1-py33_0
    dateutil: 1.5-py33_0  --> 2.1-py33_1   \n\

"""
    )

    actions["LINK"], actions["UNLINK"] = actions["UNLINK"], actions["LINK"]

    with captured() as c:
        display_actions(actions, index)

    assert (
        c.stdout
        == """
The following packages will be DOWNGRADED due to dependency conflicts:

    cython:   0.19.1-py33_0 --> 0.19-py33_0
    dateutil: 2.1-py33_1    --> 1.5-py33_0 \n\

"""
    )
示例#43
0
def solve(specs):
    return [Dist.from_string(fn) for fn in r.solve(specs)]
示例#44
0
    def test_dist_with_channel_url(self):
        # standard named channel
        url = "https://repo.anaconda.com/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2"
        d = Dist(url)
        assert d.channel == 'defaults'
        assert d.name == 'spyder-app'
        assert d.version == '2.3.8'
        assert d.build_string == 'py27_0'

        assert d.to_url() == url
        assert d.is_channel is True

        # standard url channel
        url = "https://not.real.continuum.io/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2"
        d = Dist(url)
        assert d.channel == 'defaults'  # because pkgs/anaconda is in defaults
        assert d.name == 'spyder-app'
        assert d.version == '2.3.8'
        assert d.build_string == 'py27_0'

        assert d.to_url() == url
        assert d.is_channel is True

        # another standard url channel
        url = "https://not.real.continuum.io/not/anaconda/win-64/spyder-app-2.3.8-py27_0.tar.bz2"
        d = Dist(url)
        assert d.channel == 'https://not.real.continuum.io/not/anaconda'
        assert d.name == 'spyder-app'
        assert d.version == '2.3.8'
        assert d.build_string == 'py27_0'

        assert d.to_url() == url
        assert d.is_channel is True

        # local file url that is a named channel
        conda_bld_path = join(gettempdir(), 'conda-bld')
        try:
            mkdir_p(conda_bld_path)
            with env_var('CONDA_BLD_PATH', conda_bld_path, stack_callback=conda_tests_ctxt_mgmt_def_pol):
                url = path_to_url(join_url(context.croot, 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2'))
                d = Dist(url)
                assert d.channel == 'local'
                assert d.name == 'bcrypt'
                assert d.version == '3.1.1'
                assert d.build_string == 'py35_2'

                assert d.to_url() == url
                assert d.is_channel is True
        finally:
            rm_rf(conda_bld_path)

        # local file url that is not a named channel
        url = join_url('file:///some/location/on/disk', 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2')
        d = Dist(url)
        assert d.channel == 'file:///some/location/on/disk'
        assert d.name == 'bcrypt'
        assert d.version == '3.1.1'
        assert d.build_string == 'py35_2'

        assert d.to_url() == url
        assert d.is_channel is True
 def ensure_dist_or_dict(fn):
     return _Dist.from_string(fn)
示例#46
0
def test_display_actions():
    os.environ['CONDA_SHOW_CHANNEL_URLS'] = 'False'
    reset_context(())
    actions = defaultdict(list, {"FETCH": [Dist('sympy-0.7.2-py27_0'), Dist("numpy-1.7.1-py27_0")]})
    # The older test index doesn't have the size metadata
    d = Dist.from_string('sympy-0.7.2-py27_0.tar.bz2')
    index[d] = IndexRecord.from_objects(index[d], size=4374752)
    d = Dist.from_string("numpy-1.7.1-py27_0.tar.bz2")
    index[d] = IndexRecord.from_objects(index[d], size=5994338)

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    sympy-0.7.2                |           py27_0         4.2 MB
    numpy-1.7.1                |           py27_0         5.7 MB
    ------------------------------------------------------------
                                           Total:         9.9 MB

"""

    actions = defaultdict(list, {'PREFIX':
    '/Users/aaronmeurer/anaconda/envs/test', 'SYMLINK_CONDA':
    ['/Users/aaronmeurer/anaconda'], 'LINK': ['python-3.3.2-0', 'readline-6.2-0 1', 'sqlite-3.7.13-0 1', 'tk-8.5.13-0 1', 'zlib-1.2.7-0 1']})

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following NEW packages will be INSTALLED:

    python:   3.3.2-0 \n\
    readline: 6.2-0   \n\
    sqlite:   3.7.13-0
    tk:       8.5.13-0
    zlib:     1.2.7-0 \n\

"""

    actions['UNLINK'] = actions['LINK']
    actions['LINK'] = []

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be REMOVED:

    python:   3.3.2-0 \n\
    readline: 6.2-0   \n\
    sqlite:   3.7.13-0
    tk:       8.5.13-0
    zlib:     1.2.7-0 \n\

"""

    actions = defaultdict(list, {'LINK': ['cython-0.19.1-py33_0'], 'UNLINK':
    ['cython-0.19-py33_0']})

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be UPDATED:

    cython: 0.19-py33_0 --> 0.19.1-py33_0

"""

    actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK']

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be DOWNGRADED due to dependency conflicts:

    cython: 0.19.1-py33_0 --> 0.19-py33_0

"""

    actions = defaultdict(list, {'LINK': ['cython-0.19.1-py33_0',
        'dateutil-1.5-py33_0', 'numpy-1.7.1-py33_0'], 'UNLINK':
        ['cython-0.19-py33_0', 'dateutil-2.1-py33_1', 'pip-1.3.1-py33_1']})

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following NEW packages will be INSTALLED:

    numpy:    1.7.1-py33_0

The following packages will be REMOVED:

    pip:      1.3.1-py33_1

The following packages will be UPDATED:

    cython:   0.19-py33_0  --> 0.19.1-py33_0

The following packages will be DOWNGRADED due to dependency conflicts:

    dateutil: 2.1-py33_1   --> 1.5-py33_0   \n\

"""

    actions = defaultdict(list, {'LINK': ['cython-0.19.1-py33_0',
        'dateutil-2.1-py33_1'], 'UNLINK':  ['cython-0.19-py33_0',
            'dateutil-1.5-py33_0']})

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be UPDATED:

    cython:   0.19-py33_0 --> 0.19.1-py33_0
    dateutil: 1.5-py33_0  --> 2.1-py33_1   \n\

"""

    actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK']

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """