Beispiel #1
0
def test_should_use_ephemeral_cache__disallow_binaries_and_vcs_checkout(
    disallow_binaries,
    expected,
):
    """
    Test that disallowing binaries (e.g. from passing --global-option)
    causes should_use_ephemeral_cache() to return None for VCS checkouts.
    """
    req = Requirement('pendulum')
    # Passing a VCS url causes link.is_artifact to return False.
    link = Link(url='git+https://git.example.com/pendulum.git')
    req = InstallRequirement(
        req=req,
        comes_from=None,
        constraint=False,
        editable=False,
        link=link,
        source_dir='/tmp/pip-install-9py5m2z1/pendulum',
    )
    assert not req.is_wheel
    assert not req.link.is_artifact

    format_control = FormatControl()
    if disallow_binaries:
        format_control.disallow_binaries()

    # The cache_available value doesn't matter for this test.
    ephem_cache = wheel.should_use_ephemeral_cache(
        req,
        format_control=format_control,
        autobuilding=True,
        cache_available=True,
    )
    assert ephem_cache is expected
Beispiel #2
0
def test_should_use_ephemeral_cache__disallow_binaries_and_vcs_checkout(
    disallow_binaries, expected,
):
    """
    Test that disallowing binaries (e.g. from passing --global-option)
    causes should_use_ephemeral_cache() to return None for VCS checkouts.
    """
    req = Requirement('pendulum')
    # Passing a VCS url causes link.is_artifact to return False.
    link = Link(url='git+https://git.example.com/pendulum.git')
    req = InstallRequirement(
        req=req,
        comes_from=None,
        constraint=False,
        editable=False,
        link=link,
        source_dir='/tmp/pip-install-9py5m2z1/pendulum',
    )
    assert not req.is_wheel
    assert not req.link.is_artifact

    format_control = FormatControl()
    if disallow_binaries:
        format_control.disallow_binaries()

    # The cache_available value doesn't matter for this test.
    ephem_cache = wheel.should_use_ephemeral_cache(
        req, format_control=format_control, autobuilding=True,
        cache_available=True,
    )
    assert ephem_cache is expected
Beispiel #3
0
def test_should_use_ephemeral_cache__disallow_binaries_and_vcs_checkout(
    disallow_binaries,
    expected,
):
    """
    Test that disallowing binaries (e.g. from passing --global-option)
    causes should_use_ephemeral_cache() to return None for VCS checkouts.
    """
    req = Requirement('pendulum')
    link = Link(url='git+https://git.example.com/pendulum.git')
    req = InstallRequirement(
        req=req,
        comes_from=None,
        constraint=False,
        editable=False,
        link=link,
        source_dir='/tmp/pip-install-9py5m2z1/pendulum',
    )
    assert not req.is_wheel
    assert req.link.is_vcs

    check_binary_allowed = Mock(return_value=not disallow_binaries)

    # The cache_available value doesn't matter for this test.
    ephem_cache = wheel.should_use_ephemeral_cache(
        req,
        should_unpack=True,
        cache_available=True,
        check_binary_allowed=check_binary_allowed,
    )
    assert ephem_cache is expected
Beispiel #4
0
def test_should_use_ephemeral_cache__issue_6197(
    base_name, autobuilding, cache_available, expected,
):
    """
    Regression test for: https://github.com/pypa/pip/issues/6197
    """
    req = Requirement('pendulum')
    link_url = (
        'https://files.pythonhosted.org/packages/aa/{base_name}.tar.gz'
        '#sha256=cf535d36c063575d4752af36df928882b2e0e31541b4482c97d637527'
        '85f9fcb'
    ).format(base_name=base_name)
    link = Link(
        url=link_url,
        comes_from='https://pypi.org/simple/pendulum/',
        requires_python='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
    )
    req = InstallRequirement(
        req=req,
        comes_from=None,
        constraint=False,
        editable=False,
        link=link,
        source_dir='/tmp/pip-install-9py5m2z1/pendulum',
    )
    assert not req.is_wheel
    assert req.link.is_artifact

    format_control = FormatControl()
    ephem_cache = wheel.should_use_ephemeral_cache(
        req, format_control=format_control, autobuilding=autobuilding,
        cache_available=cache_available,
    )
    assert ephem_cache is expected
Beispiel #5
0
def test_should_use_ephemeral_cache__issue_6197(
    base_name, autobuilding, cache_available, expected,
):
    """
    Regression test for: https://github.com/pypa/pip/issues/6197
    """
    req = make_test_install_req(base_name=base_name)
    assert not req.is_wheel
    assert req.link.is_artifact

    format_control = FormatControl()
    ephem_cache = wheel.should_use_ephemeral_cache(
        req, format_control=format_control, autobuilding=autobuilding,
        cache_available=cache_available,
    )
    assert ephem_cache is expected
Beispiel #6
0
def test_should_use_ephemeral_cache__issue_6197(
    base_name, autobuilding, cache_available, expected,
):
    """
    Regression test for: https://github.com/pypa/pip/issues/6197
    """
    req = make_test_install_req(base_name=base_name)
    assert not req.is_wheel
    assert req.link.is_artifact

    format_control = FormatControl()
    ephem_cache = wheel.should_use_ephemeral_cache(
        req, format_control=format_control, autobuilding=autobuilding,
        cache_available=cache_available,
    )
    assert ephem_cache is expected
Beispiel #7
0
def test_should_use_ephemeral_cache__issue_6197(
    base_name, should_unpack, cache_available, expected,
):
    """
    Regression test for: https://github.com/pypa/pip/issues/6197
    """
    req = make_test_install_req(base_name=base_name)
    assert not req.is_wheel
    assert not req.link.is_vcs

    always_true = Mock(return_value=True)

    ephem_cache = wheel.should_use_ephemeral_cache(
        req, should_unpack=should_unpack,
        cache_available=cache_available, check_binary_allowed=always_true,
    )
    assert ephem_cache is expected
Beispiel #8
0
def test_should_use_ephemeral_cache__issue_6197(
    base_name,
    autobuilding,
    cache_available,
    expected,
):
    """
    Regression test for: https://github.com/pypa/pip/issues/6197
    """
    req = Requirement('pendulum')
    link_url = (
        'https://files.pythonhosted.org/packages/aa/{base_name}.tar.gz'
        '#sha256=cf535d36c063575d4752af36df928882b2e0e31541b4482c97d637527'
        '85f9fcb').format(base_name=base_name)
    link = Link(
        url=link_url,
        comes_from='https://pypi.org/simple/pendulum/',
        requires_python='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
    )
    req = InstallRequirement(
        req=req,
        comes_from=None,
        constraint=False,
        editable=False,
        link=link,
        source_dir='/tmp/pip-install-9py5m2z1/pendulum',
    )
    assert not req.is_wheel
    assert req.link.is_artifact

    format_control = FormatControl()
    ephem_cache = wheel.should_use_ephemeral_cache(
        req,
        format_control=format_control,
        autobuilding=autobuilding,
        cache_available=cache_available,
    )
    assert ephem_cache is expected