Exemplo n.º 1
0
def test_nonexistent():
    assert raises(NoPackagesFoundError,
                  lambda: r.get_pkgs('notarealpackage 2.0*'))
    assert raises(NoPackagesFoundError,
                  lambda: r.install(['notarealpackage 2.0*']))
    # This exact version of NumPy does not exist
    assert raises(NoPackagesFoundError, lambda: r.install(['numpy 1.5']))
Exemplo n.º 2
0
def test_unsat():
    r.msd_cache = {}

    # scipy 0.12.0b1 is not built for numpy 1.5, only 1.6 and 1.7
    assert raises((RuntimeError, SystemExit), lambda: r.solve(['numpy 1.5*', 'scipy 0.12.0b1']), 'conflict')
    # numpy 1.5 does not have a python 3 package
    assert raises((RuntimeError, SystemExit), lambda: r.solve(['numpy 1.5*', 'python 3*']), 'conflict')
    assert raises((RuntimeError, SystemExit), lambda: r.solve(['numpy 1.5*', 'numpy 1.6*']), 'conflict')
Exemplo n.º 3
0
def test_unsat():
    r.msd_cache = {}

    # scipy 0.12.0b1 is not built for numpy 1.5, only 1.6 and 1.7
    assert raises((RuntimeError, SystemExit), lambda: r.solve(["numpy 1.5*", "scipy 0.12.0b1"]), "conflict")
    # numpy 1.5 does not have a python 3 package
    assert raises((RuntimeError, SystemExit), lambda: r.solve(["numpy 1.5*", "python 3*"]), "conflict")
    assert raises((RuntimeError, SystemExit), lambda: r.solve(["numpy 1.5*", "numpy 1.6*"]), "conflict")
Exemplo n.º 4
0
def test_nonexistent():
    r.msd_cache = {}

    assert raises(NoPackagesFound, lambda: r.solve(['notarealpackage 2.0*']),
                  'No packages found')
    # This exact version of NumPy does not exist
    assert raises(NoPackagesFound, lambda: r.solve(['numpy 1.5']),
                  'No packages found')
Exemplo n.º 5
0
def test_unsat():
    # scipy 0.12.0b1 is not built for numpy 1.5, only 1.6 and 1.7
    assert raises(UnsatisfiableError,
                  lambda: r.install(['numpy 1.5*', 'scipy 0.12.0b1']))
    # numpy 1.5 does not have a python 3 package
    assert raises(UnsatisfiableError,
                  lambda: r.install(['numpy 1.5*', 'python 3*']))
    assert raises(UnsatisfiableError,
                  lambda: r.install(['numpy 1.5*', 'numpy 1.6*']))
Exemplo n.º 6
0
def test_odd_even_merge():
    for n in [1, 2, 4, 8, 16]:
        A = list(range(1, n + 1))
        B = list(range(n + 1, 2 * n + 1))
        C = Clauses(n)
        merged = C.odd_even_merge(A, B)
        for i in range(n + 1):
            for j in range(n + 1):
                # Test all possible mergings of sorted lists, like [1, 1, 0,
                # 0] and [1, 0, 0, 0] -> [1, 1, 1, 0, 0, 0, 0, 0].
                Asigns = [1] * i + [-1] * (n - i)
                Bsigns = [1] * j + [-1] * (n - j)
                As = {(s * a, ) for s, a in zip(Asigns, A)}
                Bs = {(s * b, ) for s, b in zip(Bsigns, B)}
                for sol in my_itersolve(C.clauses | As | Bs):
                    a = [i in sol for i in A]
                    b = [i in sol for i in B]
                    m = [i in sol for i in merged]
                    # Check we did the above correctly
                    assert a == sorted(a, reverse=True)
                    assert b == sorted(b, reverse=True)
                    # And check that the merge is correct
                    assert m == sorted(a + b, reverse=True)

    assert raises(ValueError,
                  lambda: Clauses(4).odd_even_merge([1, 2], [2, 3, 4]))
Exemplo n.º 7
0
def test_odd_even_merge():
    for n in [1, 2, 4, 8, 16]:
        A = list(range(1, n+1))
        B = list(range(n+1, 2*n+1))
        C = Clauses(n)
        merged = C.odd_even_merge(A, B)
        for i in range(n+1):
            for j in range(n+1):
                # Test all possible mergings of sorted lists, like [1, 1, 0,
                # 0] and [1, 0, 0, 0] -> [1, 1, 1, 0, 0, 0, 0, 0].
                Asigns = [1]*i + [-1]*(n - i)
                Bsigns = [1]*j + [-1]*(n - j)
                As = {(s*a,) for s, a in zip(Asigns, A)}
                Bs = {(s*b,) for s, b in zip(Bsigns, B)}
                for sol in my_itersolve(C.clauses | As | Bs):
                    a = [i in sol for i in A]
                    b = [i in sol for i in B]
                    m = [i in sol for i in merged]
                    # Check we did the above correctly
                    assert a == sorted(a, reverse=True)
                    assert b == sorted(b, reverse=True)
                    # And check that the merge is correct
                    assert m == sorted(a + b, reverse=True)

    assert raises(ValueError, lambda: Clauses(4).odd_even_merge([1, 2], [2, 3, 4]))
Exemplo n.º 8
0
def test_optional_dependencies():
    index2 = index.copy()
    index2['package1-1.0-0.tar.bz2'] = IndexRecord(**{
        'build': '0',
        'build_number': 0,
        'depends': ['package2 >1.0 (optional)'],
        'name': 'package1',
        'requires': ['package2'],
        'version': '1.0',
    })
    index2['package2-1.0-0.tar.bz2'] = IndexRecord(**{
        'build': '0',
        'build_number': 0,
        'depends': [],
        'name': 'package2',
        'requires': [],
        'version': '1.0',
    })
    index2['package2-2.0-0.tar.bz2'] = IndexRecord(**{
        'build': '0',
        'build_number': 0,
        'depends': [],
        'name': 'package2',
        'requires': [],
        'version': '2.0',
    })
    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r = Resolve(index2)

    assert set(r.find_matches(MatchSpec('package1'))) == {
        Dist('package1-1.0-0.tar.bz2'),
    }
    assert set(r.get_reduced_index(['package1']).keys()) == {
        Dist('package1-1.0-0.tar.bz2'),
        Dist('package2-2.0-0.tar.bz2'),
    }
    assert r.install(['package1']) == [
        Dist('package1-1.0-0.tar.bz2'),
    ]
    assert r.install(['package1', 'package2']) == r.install(['package1', 'package2 >1.0']) == [
        Dist('package1-1.0-0.tar.bz2'),
        Dist('package2-2.0-0.tar.bz2'),
    ]
    assert raises(UnsatisfiableError, lambda: r.install(['package1', 'package2 <2.0']))
    assert raises(UnsatisfiableError, lambda: r.install(['package1', 'package2 1.0']))
Exemplo n.º 9
0
def test_odd_even_mergesort():
    for n in [1, 2, 4, 8]:
        A = list(range(1, n + 1))
        C = Clauses(n)
        S = C.odd_even_mergesort(A)
        # Note, the zero-one principle states we only need to test lists of
        # 0's and
        # 1's. https://en.wikipedia.org/wiki/Sorting_network#Zero-one_principle.
        for sol in my_itersolve(C.clauses):
            a = [i in sol for i in A]
            s = [i in sol for i in S]
            assert s == sorted(a, reverse=True)

    # TODO: n > 8 takes too long to test all combinations, but maybe we should test
    # some random combinations.

    assert raises(ValueError,
                  lambda: Clauses(5).odd_even_mergesort([1, 2, 3, 4, 5]))

    # Make sure it works with booleans
    for n in [1, 2, 4]:
        for item in product(*[[true, false]] * n):
            assert list(Clauses(0).odd_even_mergesort(item)) == sorted(
                item, reverse=True)

    # The most important use-case is extending a non-power of 2 length list
    # with false.
    for n in range(1, 9):
        next_power_of_2 = 2**ceil(log2(n))
        assert n <= next_power_of_2
        for item in product(*[[true, false]] * (next_power_of_2 - n)):

            A = list(range(1, n + 1)) + list(item)
            C = Clauses(n)
            S = C.odd_even_mergesort(A)

            for sol in my_itersolve(C.clauses):
                a = [
                    boolize(i) if isinstance(boolize(i), bool) else i in sol
                    for i in A
                ]
                s = [
                    boolize(i) if isinstance(boolize(i), bool) else i in sol
                    for i in S
                ]

                assert s == sorted(a, reverse=True), (a, s, sol)
Exemplo n.º 10
0
def test_odd_even_mergesort():
    for n in [1, 2, 4, 8]:
        A = list(range(1, n+1))
        C = Clauses(n)
        S = C.odd_even_mergesort(A)
        # Note, the zero-one principle states we only need to test lists of
        # 0's and
        # 1's. https://en.wikipedia.org/wiki/Sorting_network#Zero-one_principle.
        for sol in my_itersolve(C.clauses):
            a = [i in sol for i in A]
            s = [i in sol for i in S]
            assert s == sorted(a, reverse=True)

    # TODO: n > 8 takes too long to test all combinations, but maybe we should test
    # some random combinations.

    assert raises(ValueError, lambda: Clauses(5).odd_even_mergesort([1, 2, 3,
    4, 5]))

    # Make sure it works with booleans
    for n in [1, 2, 4]:
        for item in product(*[[true, false]]*n):
            assert list(Clauses(0).odd_even_mergesort(item)) == sorted(item, reverse=True)

    # The most important use-case is extending a non-power of 2 length list
    # with false.
    for n in range(1, 9):
        next_power_of_2 = 2**ceil(log2(n))
        assert n <= next_power_of_2
        for item in product(*[[true, false]]*(next_power_of_2 - n)):

            A = list(range(1, n + 1)) + list(item)
            C = Clauses(n)
            S = C.odd_even_mergesort(A)

            for sol in my_itersolve(C.clauses):
                a = [boolize(i) if isinstance(boolize(i), bool) else
                    i in sol for i in A]
                s = [boolize(i) if isinstance(boolize(i), bool) else
                    i in sol for i in S]

                assert s == sorted(a, reverse=True), (a, s, sol)
Exemplo n.º 11
0
def test_minimal_unsatisfiable_subset():
    assert raises(ValueError, lambda: minimal_unsatisfiable_subset([[1]]))

    clauses = [[-10], [1], [5], [2, 3], [3, 4], [5, 2], [-7], [2], [3],
               [-2, -3, 5], [7, 8, 9, 10], [-8], [-9]]
    res = minimal_unsatisfiable_subset(clauses)
    assert sorted(res) == [[-10], [-9], [-8], [-7], [7, 8, 9, 10]]
    assert not sat(res)

    clauses = [[1, 3], [2, 3], [-1], [4], [3], [-3]]
    for perm in permutations(clauses):
        res = minimal_unsatisfiable_subset(clauses)
        assert sorted(res) == [[-3], [3]]
        assert not sat(res)

    clauses = [[1], [-1], [2], [-2], [3, 4], [4]]
    for perm in permutations(clauses):
        res = minimal_unsatisfiable_subset(perm)
        assert sorted(res) in [[[-1], [1]], [[-2], [2]]]
        assert not sat(res)
Exemplo n.º 12
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
Exemplo n.º 13
0
def test_minimal_unsatisfiable_subset():
    assert raises(ValueError, lambda: minimal_unsatisfiable_subset([[1]]))

    clauses = [[-10], [1], [5], [2, 3], [3, 4], [5, 2], [-7], [2], [3], [-2,
        -3, 5], [7, 8, 9, 10], [-8], [-9]]
    res = minimal_unsatisfiable_subset(clauses)
    assert sorted(res) == [[-10], [-9], [-8], [-7], [7, 8, 9, 10]]
    assert not sat(res)


    clauses = [[1, 3], [2, 3], [-1], [4], [3], [-3]]
    for perm in permutations(clauses):
        res = minimal_unsatisfiable_subset(clauses)
        assert sorted(res) == [[-3], [3]]
        assert not sat(res)

    clauses = [[1], [-1], [2], [-2], [3, 4], [4]]
    for perm in permutations(clauses):
        res = minimal_unsatisfiable_subset(perm)
        assert sorted(res) in [[[-1], [1]], [[-2], [2]]]
        assert not sat(res)
Exemplo n.º 14
0
def test_minimal_unsatisfiable_subset():
    def sat(val):
        return Clauses(max(abs(v) for v in chain(*val))).sat(val)
    assert raises(ValueError, lambda: minimal_unsatisfiable_subset([[1]], sat))

    clauses = [[-10], [1], [5], [2, 3], [3, 4], [5, 2], [-7], [2], [3],
        [-2, -3, 5], [7, 8, 9, 10], [-8], [-9]]
    res = minimal_unsatisfiable_subset(clauses, sat)
    assert sorted(res) == [[-10], [-9], [-8], [-7], [7, 8, 9, 10]]
    assert not sat(res)

    clauses = [[1, 3], [2, 3], [-1], [4], [3], [-3]]
    for perm in permutations(clauses):
        res = minimal_unsatisfiable_subset(clauses, sat)
        assert sorted(res) == [[-3], [3]]
        assert not sat(res)

    clauses = [[1], [-1], [2], [-2], [3, 4], [4]]
    for perm in permutations(clauses):
        res = minimal_unsatisfiable_subset(perm, sat)
        assert sorted(res) in [[[-1], [1]], [[-2], [2]]]
        assert not sat(res)
Exemplo n.º 15
0
def test_minimal_unsatisfiable_subset():
    def sat(val):
        return Clauses(max(abs(v) for v in chain(*val))).sat(val)
    assert raises(ValueError, lambda: minimal_unsatisfiable_subset([[1]], sat))

    clauses = [[-10], [1], [5], [2, 3], [3, 4], [5, 2], [-7], [2], [3],
        [-2, -3, 5], [7, 8, 9, 10], [-8], [-9]]
    res = minimal_unsatisfiable_subset(clauses, sat)
    assert sorted(res) == [[-10], [-9], [-8], [-7], [7, 8, 9, 10]]
    assert not sat(res)

    clauses = [[1, 3], [2, 3], [-1], [4], [3], [-3]]
    for perm in permutations(clauses):
        res = minimal_unsatisfiable_subset(clauses, sat)
        assert sorted(res) == [[-3], [3]]
        assert not sat(res)

    clauses = [[1], [-1], [2], [-2], [3, 4], [4]]
    for perm in permutations(clauses):
        res = minimal_unsatisfiable_subset(perm, sat)
        assert sorted(res) in [[[-1], [1]], [[-2], [2]]]
        assert not sat(res)
Exemplo n.º 16
0
def test_package_ordering():
    sympy_071 = Package("sympy-0.7.1-py27_0.tar.bz2", r.index["sympy-0.7.1-py27_0.tar.bz2"])
    sympy_072 = Package("sympy-0.7.2-py27_0.tar.bz2", r.index["sympy-0.7.2-py27_0.tar.bz2"])
    python_275 = Package("python-2.7.5-0.tar.bz2", r.index["python-2.7.5-0.tar.bz2"])
    numpy = Package("numpy-1.7.1-py27_0.tar.bz2", r.index["numpy-1.7.1-py27_0.tar.bz2"])
    numpy_mkl = Package("numpy-1.7.1-py27_p0.tar.bz2", r.index["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
Exemplo n.º 17
0
def test_nonexistent():
    assert not r.find_matches(MatchSpec('notarealpackage 2.0*'))
    assert raises(NoPackagesFoundError, lambda: r.install(['notarealpackage 2.0*']))
    # This exact version of NumPy does not exist
    assert raises(NoPackagesFoundError, lambda: r.install(['numpy 1.5']))
Exemplo n.º 18
0
def test_nonexistent_deps():
    index2 = index.copy()
    index2['mypackage-1.0-py33_0.tar.bz2'] = IndexRecord(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*', 'notarealpackage 2.0*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.0',
    })
    index2['mypackage-1.1-py33_0.tar.bz2'] = IndexRecord(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.1',
    })
    index2['anotherpackage-1.0-py33_0.tar.bz2'] = IndexRecord(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage 1.1'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage 1.1'],
        'version': '1.0',
    })
    index2['anotherpackage-2.0-py33_0.tar.bz2'] = IndexRecord(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage'],
        'version': '2.0',
    })
    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r = Resolve(index2)

    assert set(r.find_matches(MatchSpec('mypackage'))) == {
        Dist('mypackage-1.0-py33_0.tar.bz2'),
        Dist('mypackage-1.1-py33_0.tar.bz2'),
    }
    assert set(d.to_filename() for d in r.get_reduced_index(['mypackage']).keys()) == {
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.1.2-py33_0.tar.bz2',
        'nose-1.2.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.0-2.tar.bz2',
        'python-3.3.0-3.tar.bz2',
        'python-3.3.0-4.tar.bz2',
        'python-3.3.0-pro0.tar.bz2',
        'python-3.3.0-pro1.tar.bz2',
        'python-3.3.1-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2'}

    target_result = r.install(['mypackage'])
    assert target_result == r.install(['mypackage 1.1'])
    assert target_result == [
        Dist(add_defaults_if_no_channel(dname)) for dname in [
        '<unknown>::mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]]
    assert raises(NoPackagesFoundError, lambda: r.install(['mypackage 1.0']))
    assert raises(NoPackagesFoundError, lambda: r.install(['mypackage 1.0', 'burgertime 1.0']))

    assert r.install(['anotherpackage 1.0']) == [
        Dist(add_defaults_if_no_channel(dname)) for dname in [
        '<unknown>::anotherpackage-1.0-py33_0.tar.bz2',
        '<unknown>::mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]]

    assert r.install(['anotherpackage']) == [
        Dist(add_defaults_if_no_channel(dname)) for dname in [
        '<unknown>::anotherpackage-2.0-py33_0.tar.bz2',
        '<unknown>::mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]]

    # This time, the latest version is messed up
    index3 = index.copy()
    index3['mypackage-1.1-py33_0.tar.bz2'] = IndexRecord(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*', 'notarealpackage 2.0*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.1',
    })
    index3['mypackage-1.0-py33_0.tar.bz2'] = IndexRecord(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.0',
    })
    index3['anotherpackage-1.0-py33_0.tar.bz2'] = IndexRecord(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage 1.0'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage 1.0'],
        'version': '1.0',
    })
    index3['anotherpackage-2.0-py33_0.tar.bz2'] = IndexRecord(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage'],
        'version': '2.0',
    })
    index3 = {Dist(key): value for key, value in iteritems(index3)}
    r = Resolve(index3)

    assert set(d.to_filename() for d in r.find_matches(MatchSpec('mypackage'))) == {
        'mypackage-1.0-py33_0.tar.bz2',
        'mypackage-1.1-py33_0.tar.bz2',
        }
    assert set(d.to_filename() for d in r.get_reduced_index(['mypackage']).keys()) == {
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.1.2-py33_0.tar.bz2',
        'nose-1.2.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.0-2.tar.bz2',
        'python-3.3.0-3.tar.bz2',
        'python-3.3.0-4.tar.bz2',
        'python-3.3.0-pro0.tar.bz2',
        'python-3.3.0-pro1.tar.bz2',
        'python-3.3.1-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-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.install(['mypackage']) == r.install(['mypackage 1.0']) == [
        Dist(add_defaults_if_no_channel(dname)) for dname in [
        '<unknown>::mypackage-1.0-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]]
    assert raises(NoPackagesFoundError, lambda: r.install(['mypackage 1.1']))

    assert r.install(['anotherpackage 1.0']) == [
        Dist(add_defaults_if_no_channel(dname))for dname in [
        '<unknown>::anotherpackage-1.0-py33_0.tar.bz2',
        '<unknown>::mypackage-1.0-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]]

    # If recursive checking is working correctly, this will give
    # anotherpackage 2.0, not anotherpackage 1.0
    assert r.install(['anotherpackage']) == [
        Dist(add_defaults_if_no_channel(dname))for dname in [
        '<unknown>::anotherpackage-2.0-py33_0.tar.bz2',
        '<unknown>::mypackage-1.0-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]]
Exemplo n.º 19
0
def test_nonexistent():
    assert not r.find_matches(MatchSpec('notarealpackage 2.0*'))
    assert raises(NoPackagesFoundError, lambda: r.install(['notarealpackage 2.0*']))
    # This exact version of NumPy does not exist
    assert raises(NoPackagesFoundError, lambda: r.install(['numpy 1.5']))
Exemplo n.º 20
0
def test_nonexistent_deps():
    index2 = index.copy()
    index2["mypackage-1.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "python 3.3*", "notarealpackage 2.0*"],
        "name": "mypackage",
        "requires": ["nose 1.2.1", "python 3.3"],
        "version": "1.0",
    }
    index2["mypackage-1.1-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "python 3.3*"],
        "name": "mypackage",
        "requires": ["nose 1.2.1", "python 3.3"],
        "version": "1.1",
    }
    index2["anotherpackage-1.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "mypackage 1.1"],
        "name": "anotherpackage",
        "requires": ["nose", "mypackage 1.1"],
        "version": "1.0",
    }
    index2["anotherpackage-2.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "mypackage"],
        "name": "anotherpackage",
        "requires": ["nose", "mypackage"],
        "version": "2.0",
    }
    r = Resolve(index2)

    assert set(r.find_matches(MatchSpec("mypackage"))) == {
        "mypackage-1.0-py33_0.tar.bz2",
        "mypackage-1.1-py33_0.tar.bz2",
    }
    assert set(r.get_dists(["mypackage"]).keys()) == {
        "mypackage-1.1-py33_0.tar.bz2",
        "nose-1.1.2-py26_0.tar.bz2",
        "nose-1.1.2-py27_0.tar.bz2",
        "nose-1.1.2-py33_0.tar.bz2",
        "nose-1.2.1-py26_0.tar.bz2",
        "nose-1.2.1-py27_0.tar.bz2",
        "nose-1.2.1-py33_0.tar.bz2",
        "nose-1.3.0-py26_0.tar.bz2",
        "nose-1.3.0-py27_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-2.6.8-1.tar.bz2",
        "python-2.6.8-2.tar.bz2",
        "python-2.6.8-3.tar.bz2",
        "python-2.6.8-4.tar.bz2",
        "python-2.6.8-5.tar.bz2",
        "python-2.6.8-6.tar.bz2",
        "python-2.7.3-2.tar.bz2",
        "python-2.7.3-3.tar.bz2",
        "python-2.7.3-4.tar.bz2",
        "python-2.7.3-5.tar.bz2",
        "python-2.7.3-6.tar.bz2",
        "python-2.7.3-7.tar.bz2",
        "python-2.7.4-0.tar.bz2",
        "python-2.7.5-0.tar.bz2",
        "python-3.3.0-2.tar.bz2",
        "python-3.3.0-3.tar.bz2",
        "python-3.3.0-4.tar.bz2",
        "python-3.3.0-pro0.tar.bz2",
        "python-3.3.0-pro1.tar.bz2",
        "python-3.3.1-0.tar.bz2",
        "python-3.3.2-0.tar.bz2",
        "readline-6.2-0.tar.bz2",
        "sqlite-3.7.13-0.tar.bz2",
        "system-5.8-0.tar.bz2",
        "system-5.8-1.tar.bz2",
        "tk-8.5.13-0.tar.bz2",
        "zlib-1.2.7-0.tar.bz2",
    }

    assert set(r.get_dists(["mypackage"], max_only=True).keys()) == {
        "mypackage-1.1-py33_0.tar.bz2",
        "nose-1.3.0-py26_0.tar.bz2",
        "nose-1.3.0-py27_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-2.6.8-6.tar.bz2",
        "python-2.7.5-0.tar.bz2",
        "python-3.3.2-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",
        "zlib-1.2.7-0.tar.bz2",
    }

    assert (
        r.solve(["mypackage"])
        == r.solve(["mypackage 1.1"])
        == [
            "mypackage-1.1-py33_0.tar.bz2",
            "nose-1.3.0-py33_0.tar.bz2",
            "openssl-1.0.1c-0.tar.bz2",
            "python-3.3.2-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",
            "zlib-1.2.7-0.tar.bz2",
        ]
    )
    assert raises(NoPackagesFound, lambda: r.solve(["mypackage 1.0"]))

    assert r.solve(["anotherpackage 1.0"]) == [
        "anotherpackage-1.0-py33_0.tar.bz2",
        "mypackage-1.1-py33_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-3.3.2-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",
        "zlib-1.2.7-0.tar.bz2",
    ]

    assert r.solve(["anotherpackage"]) == [
        "anotherpackage-2.0-py33_0.tar.bz2",
        "mypackage-1.1-py33_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-3.3.2-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",
        "zlib-1.2.7-0.tar.bz2",
    ]

    # This time, the latest version is messed up
    index3 = index.copy()
    index3["mypackage-1.1-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "python 3.3*", "notarealpackage 2.0*"],
        "name": "mypackage",
        "requires": ["nose 1.2.1", "python 3.3"],
        "version": "1.1",
    }
    index3["mypackage-1.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "python 3.3*"],
        "name": "mypackage",
        "requires": ["nose 1.2.1", "python 3.3"],
        "version": "1.0",
    }
    index3["anotherpackage-1.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "mypackage 1.0"],
        "name": "anotherpackage",
        "requires": ["nose", "mypackage 1.0"],
        "version": "1.0",
    }
    index3["anotherpackage-2.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "mypackage"],
        "name": "anotherpackage",
        "requires": ["nose", "mypackage"],
        "version": "2.0",
    }
    r = Resolve(index3)

    assert set(r.find_matches(MatchSpec("mypackage"))) == {
        "mypackage-1.0-py33_0.tar.bz2",
        "mypackage-1.1-py33_0.tar.bz2",
    }
    assert set(r.get_dists(["mypackage"]).keys()) == {
        "mypackage-1.0-py33_0.tar.bz2",
        "nose-1.1.2-py26_0.tar.bz2",
        "nose-1.1.2-py27_0.tar.bz2",
        "nose-1.1.2-py33_0.tar.bz2",
        "nose-1.2.1-py26_0.tar.bz2",
        "nose-1.2.1-py27_0.tar.bz2",
        "nose-1.2.1-py33_0.tar.bz2",
        "nose-1.3.0-py26_0.tar.bz2",
        "nose-1.3.0-py27_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-2.6.8-1.tar.bz2",
        "python-2.6.8-2.tar.bz2",
        "python-2.6.8-3.tar.bz2",
        "python-2.6.8-4.tar.bz2",
        "python-2.6.8-5.tar.bz2",
        "python-2.6.8-6.tar.bz2",
        "python-2.7.3-2.tar.bz2",
        "python-2.7.3-3.tar.bz2",
        "python-2.7.3-4.tar.bz2",
        "python-2.7.3-5.tar.bz2",
        "python-2.7.3-6.tar.bz2",
        "python-2.7.3-7.tar.bz2",
        "python-2.7.4-0.tar.bz2",
        "python-2.7.5-0.tar.bz2",
        "python-3.3.0-2.tar.bz2",
        "python-3.3.0-3.tar.bz2",
        "python-3.3.0-4.tar.bz2",
        "python-3.3.0-pro0.tar.bz2",
        "python-3.3.0-pro1.tar.bz2",
        "python-3.3.1-0.tar.bz2",
        "python-3.3.2-0.tar.bz2",
        "readline-6.2-0.tar.bz2",
        "sqlite-3.7.13-0.tar.bz2",
        "system-5.8-0.tar.bz2",
        "system-5.8-1.tar.bz2",
        "tk-8.5.13-0.tar.bz2",
        "zlib-1.2.7-0.tar.bz2",
    }

    assert raises(NoPackagesFound, lambda: r.get_dists(["mypackage"], max_only=True))

    assert (
        r.solve(["mypackage"])
        == r.solve(["mypackage 1.0"])
        == [
            "mypackage-1.0-py33_0.tar.bz2",
            "nose-1.3.0-py33_0.tar.bz2",
            "openssl-1.0.1c-0.tar.bz2",
            "python-3.3.2-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",
            "zlib-1.2.7-0.tar.bz2",
        ]
    )
    assert raises(NoPackagesFound, lambda: r.solve(["mypackage 1.1"]))

    assert r.solve(["anotherpackage 1.0"]) == [
        "anotherpackage-1.0-py33_0.tar.bz2",
        "mypackage-1.0-py33_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-3.3.2-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",
        "zlib-1.2.7-0.tar.bz2",
    ]

    # If recursive checking is working correctly, this will give
    # anotherpackage 2.0, not anotherpackage 1.0
    assert r.solve(["anotherpackage"]) == [
        "anotherpackage-2.0-py33_0.tar.bz2",
        "mypackage-1.0-py33_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-3.3.2-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",
        "zlib-1.2.7-0.tar.bz2",
    ]
Exemplo n.º 21
0
def test_nonexistent():
    r.msd_cache = {}

    assert raises(NoPackagesFound, lambda: r.solve(["notarealpackage 2.0*"]), "No packages found")
    # This exact version of NumPy does not exist
    assert raises(NoPackagesFound, lambda: r.solve(["numpy 1.5"]), "No packages found")
Exemplo n.º 22
0
def test_optional_dependencies():
    index2 = index.copy()
    index2['package1-1.0-0.tar.bz2'] = IndexRecord(
        **{
            "channel": "defaults",
            "subdir": context.subdir,
            "md5": "0123456789",
            "fn": "doesnt-matter-here",
            'build': '0',
            'build_number': 0,
            'constrains': ['package2 >1.0'],
            'name': 'package1',
            'requires': ['package2'],
            'version': '1.0',
        })
    index2['package2-1.0-0.tar.bz2'] = IndexRecord(
        **{
            "channel": "defaults",
            "subdir": context.subdir,
            "md5": "0123456789",
            "fn": "doesnt-matter-here",
            'build': '0',
            'build_number': 0,
            'depends': [],
            'name': 'package2',
            'requires': [],
            'version': '1.0',
        })
    index2['package2-2.0-0.tar.bz2'] = IndexRecord(
        **{
            "channel": "defaults",
            "subdir": context.subdir,
            "md5": "0123456789",
            "fn": "doesnt-matter-here",
            'build': '0',
            'build_number': 0,
            'depends': [],
            'name': 'package2',
            'requires': [],
            'version': '2.0',
        })
    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r = Resolve(index2)

    assert set(r.find_matches(MatchSpec('package1'))) == {
        Dist('package1-1.0-0.tar.bz2'),
    }
    assert set(r.get_reduced_index(['package1']).keys()) == {
        Dist('package1-1.0-0.tar.bz2'),
        Dist('package2-2.0-0.tar.bz2'),
    }
    assert r.install(['package1']) == [
        Dist('package1-1.0-0.tar.bz2'),
    ]
    assert r.install(['package1', 'package2']) == r.install(
        ['package1', 'package2 >1.0']) == [
            Dist('package1-1.0-0.tar.bz2'),
            Dist('package2-2.0-0.tar.bz2'),
        ]
    assert raises(UnsatisfiableError,
                  lambda: r.install(['package1', 'package2 <2.0']))
    assert raises(UnsatisfiableError,
                  lambda: r.install(['package1', 'package2 1.0']))
Exemplo n.º 23
0
def test_nonexistent_deps():
    index2 = index.copy()
    index2['mypackage-1.0-py33_0.tar.bz2'] = Record(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*', 'notarealpackage 2.0*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.0',
    })
    index2['mypackage-1.1-py33_0.tar.bz2'] = Record(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.1',
    })
    index2['anotherpackage-1.0-py33_0.tar.bz2'] = Record(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage 1.1'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage 1.1'],
        'version': '1.0',
    })
    index2['anotherpackage-2.0-py33_0.tar.bz2'] = Record(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage'],
        'version': '2.0',
    })
    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r = Resolve(index2)

    assert set(r.find_matches(MatchSpec('mypackage'))) == {
        Dist('mypackage-1.0-py33_0.tar.bz2'),
        Dist('mypackage-1.1-py33_0.tar.bz2'),
    }
    assert set(d.to_filename() for d in r.get_reduced_index(['mypackage']).keys()) == {
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.1.2-py33_0.tar.bz2',
        'nose-1.2.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.0-2.tar.bz2',
        'python-3.3.0-3.tar.bz2',
        'python-3.3.0-4.tar.bz2',
        'python-3.3.0-pro0.tar.bz2',
        'python-3.3.0-pro1.tar.bz2',
        'python-3.3.1-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-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.install(['mypackage']) == r.install(['mypackage 1.1']) == [Dist(dname) for dname in [
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]]
    assert raises(NoPackagesFoundError, lambda: r.install(['mypackage 1.0']))
    assert raises(NoPackagesFoundError, lambda: r.install(['mypackage 1.0', 'burgertime 1.0']))

    assert r.install(['anotherpackage 1.0']) == [Dist(dname) for dname in [
        'anotherpackage-1.0-py33_0.tar.bz2',
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]]

    assert r.install(['anotherpackage']) == [Dist(dname) for dname in [
        'anotherpackage-2.0-py33_0.tar.bz2',
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]]

    # This time, the latest version is messed up
    index3 = index.copy()
    index3['mypackage-1.1-py33_0.tar.bz2'] = Record(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*', 'notarealpackage 2.0*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.1',
    })
    index3['mypackage-1.0-py33_0.tar.bz2'] = Record(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.0',
    })
    index3['anotherpackage-1.0-py33_0.tar.bz2'] = Record(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage 1.0'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage 1.0'],
        'version': '1.0',
    })
    index3['anotherpackage-2.0-py33_0.tar.bz2'] = Record(**{
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage'],
        'version': '2.0',
    })
    index3 = {Dist(key): value for key, value in iteritems(index3)}
    r = Resolve(index3)

    assert set(d.to_filename() for d in r.find_matches(MatchSpec('mypackage'))) == {
        'mypackage-1.0-py33_0.tar.bz2',
        'mypackage-1.1-py33_0.tar.bz2',
        }
    assert set(d.to_filename() for d in r.get_reduced_index(['mypackage']).keys()) == {
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.1.2-py33_0.tar.bz2',
        'nose-1.2.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.0-2.tar.bz2',
        'python-3.3.0-3.tar.bz2',
        'python-3.3.0-4.tar.bz2',
        'python-3.3.0-pro0.tar.bz2',
        'python-3.3.0-pro1.tar.bz2',
        'python-3.3.1-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-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.install(['mypackage']) == r.install(['mypackage 1.0']) == [Dist(dname) for dname in [
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]]
    assert raises(NoPackagesFoundError, lambda: r.install(['mypackage 1.1']))

    assert r.install(['anotherpackage 1.0']) == [Dist(dname) for dname in [
        'anotherpackage-1.0-py33_0.tar.bz2',
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]]

    # If recursive checking is working correctly, this will give
    # anotherpackage 2.0, not anotherpackage 1.0
    assert r.install(['anotherpackage']) == [Dist(dname) for dname in [
        'anotherpackage-2.0-py33_0.tar.bz2',
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]]
Exemplo n.º 24
0
def test_nonexistent():
    assert raises(NoPackagesFoundError, lambda: r.get_pkgs('notarealpackage 2.0*'))
    assert raises(NoPackagesFoundError, lambda: r.install(['notarealpackage 2.0*']))
    # This exact version of NumPy does not exist
    assert raises(NoPackagesFoundError, lambda: r.install(['numpy 1.5']))
Exemplo n.º 25
0
def test_unsat():
    # scipy 0.12.0b1 is not built for numpy 1.5, only 1.6 and 1.7
    assert raises(UnsatisfiableError, lambda: r.install(['numpy 1.5*', 'scipy 0.12.0b1']))
    # numpy 1.5 does not have a python 3 package
    assert raises(UnsatisfiableError, lambda: r.install(['numpy 1.5*', 'python 3*']))
    assert raises(UnsatisfiableError, lambda: r.install(['numpy 1.5*', 'numpy 1.6*']))
Exemplo n.º 26
0
def test_nonexistent_deps():
    index2 = index.copy()
    index2['mypackage-1.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*', 'notarealpackage 2.0*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.0',
    }
    index2['mypackage-1.1-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.1',
    }
    index2['anotherpackage-1.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage 1.1'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage 1.1'],
        'version': '1.0',
    }
    index2['anotherpackage-2.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage'],
        'version': '2.0',
    }
    r = Resolve(index2)

    assert set(r.find_matches(MatchSpec('mypackage'))) == {
        'mypackage-1.0-py33_0.tar.bz2',
        'mypackage-1.1-py33_0.tar.bz2',
    }
    assert set(r.get_dists(['mypackage']).keys()) == {
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.1.2-py26_0.tar.bz2',
        'nose-1.1.2-py27_0.tar.bz2',
        'nose-1.1.2-py33_0.tar.bz2',
        'nose-1.2.1-py26_0.tar.bz2',
        'nose-1.2.1-py27_0.tar.bz2',
        'nose-1.2.1-py33_0.tar.bz2',
        'nose-1.3.0-py26_0.tar.bz2',
        'nose-1.3.0-py27_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-2.6.8-1.tar.bz2',
        'python-2.6.8-2.tar.bz2',
        'python-2.6.8-3.tar.bz2',
        'python-2.6.8-4.tar.bz2',
        'python-2.6.8-5.tar.bz2',
        'python-2.6.8-6.tar.bz2',
        'python-2.7.3-2.tar.bz2',
        'python-2.7.3-3.tar.bz2',
        'python-2.7.3-4.tar.bz2',
        'python-2.7.3-5.tar.bz2',
        'python-2.7.3-6.tar.bz2',
        'python-2.7.3-7.tar.bz2',
        'python-2.7.4-0.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'python-3.3.0-2.tar.bz2',
        'python-3.3.0-3.tar.bz2',
        'python-3.3.0-4.tar.bz2',
        'python-3.3.0-pro0.tar.bz2',
        'python-3.3.0-pro1.tar.bz2',
        'python-3.3.1-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    }

    assert set(r.get_dists(['mypackage'], max_only=True).keys()) == {
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py26_0.tar.bz2',
        'nose-1.3.0-py27_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-2.6.8-6.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    }

    assert r.solve(['mypackage']) == r.solve(['mypackage 1.1']) == [
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]
    assert raises(NoPackagesFound, lambda: r.solve(['mypackage 1.0']))

    assert r.solve(['anotherpackage 1.0']) == [
        'anotherpackage-1.0-py33_0.tar.bz2',
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]

    assert r.solve(['anotherpackage']) == [
        'anotherpackage-2.0-py33_0.tar.bz2',
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]

    # This time, the latest version is messed up
    index3 = index.copy()
    index3['mypackage-1.1-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*', 'notarealpackage 2.0*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.1',
    }
    index3['mypackage-1.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.0',
    }
    index3['anotherpackage-1.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage 1.0'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage 1.0'],
        'version': '1.0',
    }
    index3['anotherpackage-2.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage'],
        'version': '2.0',
    }
    r = Resolve(index3)

    assert set(r.find_matches(MatchSpec('mypackage'))) == {
        'mypackage-1.0-py33_0.tar.bz2',
        'mypackage-1.1-py33_0.tar.bz2',
        }
    assert set(r.get_dists(['mypackage']).keys()) == {
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.1.2-py26_0.tar.bz2',
        'nose-1.1.2-py27_0.tar.bz2',
        'nose-1.1.2-py33_0.tar.bz2',
        'nose-1.2.1-py26_0.tar.bz2',
        'nose-1.2.1-py27_0.tar.bz2',
        'nose-1.2.1-py33_0.tar.bz2',
        'nose-1.3.0-py26_0.tar.bz2',
        'nose-1.3.0-py27_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-2.6.8-1.tar.bz2',
        'python-2.6.8-2.tar.bz2',
        'python-2.6.8-3.tar.bz2',
        'python-2.6.8-4.tar.bz2',
        'python-2.6.8-5.tar.bz2',
        'python-2.6.8-6.tar.bz2',
        'python-2.7.3-2.tar.bz2',
        'python-2.7.3-3.tar.bz2',
        'python-2.7.3-4.tar.bz2',
        'python-2.7.3-5.tar.bz2',
        'python-2.7.3-6.tar.bz2',
        'python-2.7.3-7.tar.bz2',
        'python-2.7.4-0.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'python-3.3.0-2.tar.bz2',
        'python-3.3.0-3.tar.bz2',
        'python-3.3.0-4.tar.bz2',
        'python-3.3.0-pro0.tar.bz2',
        'python-3.3.0-pro1.tar.bz2',
        'python-3.3.1-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    }

    assert raises(NoPackagesFound, lambda: r.get_dists(['mypackage'], max_only=True))

    assert r.solve(['mypackage']) == r.solve(['mypackage 1.0']) == [
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]
    assert raises(NoPackagesFound, lambda: r.solve(['mypackage 1.1']))


    assert r.solve(['anotherpackage 1.0']) == [
        'anotherpackage-1.0-py33_0.tar.bz2',
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]

    # If recursive checking is working correctly, this will give
    # anotherpackage 2.0, not anotherpackage 1.0
    assert r.solve(['anotherpackage']) == [
        'anotherpackage-2.0-py33_0.tar.bz2',
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-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',
        'zlib-1.2.7-0.tar.bz2',
    ]