test_install_index.py 2.1 KB
Newer Older
1
import os
2
import textwrap
3
import urllib.parse
D
Donald Stufft 已提交
4

5
import pytest
6

7 8 9

@pytest.mark.usefixtures("with_wheel")
def test_find_links_relative_path(script, data):
10
    """Test find-links as a relative path."""
D
Donald Stufft 已提交
11
    result = script.pip(
12 13 14 15 16
        "install",
        "parent==0.1",
        "--no-index",
        "--find-links",
        "packages/",
17 18
        cwd=data.root,
    )
19 20
    dist_info_folder = script.site_packages / "parent-0.1.dist-info"
    initools_folder = script.site_packages / "parent"
21
    result.did_create(dist_info_folder)
22
    result.did_create(initools_folder)
23 24


25 26
@pytest.mark.usefixtures("with_wheel")
def test_find_links_requirements_file_relative_path(script, data):
27
    """Test find-links as a relative path to a reqs file."""
28 29 30
    script.scratch_path.joinpath("test-req.txt").write_text(
        textwrap.dedent(
            """
31
        --no-index
D
Deepak Sharma 已提交
32
        --find-links={}
33
        parent==0.1
34 35 36 37 38
        """.format(
                data.packages.replace(os.path.sep, "/")
            )
        )
    )
D
Donald Stufft 已提交
39
    result = script.pip(
40 41
        "install",
        "-r",
D
Donald Stufft 已提交
42
        script.scratch_path / "test-req.txt",
43 44
        cwd=data.root,
    )
45 46
    dist_info_folder = script.site_packages / "parent-0.1.dist-info"
    initools_folder = script.site_packages / "parent"
47
    result.did_create(dist_info_folder)
48
    result.did_create(initools_folder)
49 50


51 52
@pytest.mark.usefixtures("with_wheel")
def test_install_from_file_index_hash_link(script, data):
53
    """
54 55
    Test that a pkg can be installed from a file:// index using a link with a
    hash
56
    """
57 58
    result = script.pip("install", "-i", data.index_url(), "simple==1.0")
    dist_info_folder = script.site_packages / "simple-1.0.dist-info"
59
    result.did_create(dist_info_folder)
60 61


62 63
@pytest.mark.usefixtures("with_wheel")
def test_file_index_url_quoting(script, data):
64 65 66
    """
    Test url quoting of file index url with a space
    """
67
    index_url = data.index_url(urllib.parse.quote("in dex"))
68 69 70
    result = script.pip("install", "-vvv", "--index-url", index_url, "simple")
    result.did_create(script.site_packages / "simple")
    result.did_create(script.site_packages / "simple-1.0.dist-info")