コード例 #1
0
def _change_test_package_submodule(env, submodule_path):
    write_file(submodule_path/'testfile', 'this is a changed file')
    write_file(submodule_path/'testfile2', 'this is an added file')
    env.run('git', 'add', '.', cwd=submodule_path)
    env.run('git', 'commit', '-q',
            '--author', 'Pip <*****@*****.**>',
            '-am', 'submodule change', cwd=submodule_path)
コード例 #2
0
ファイル: test_cleanup.py プロジェクト: michaeta/pip
def test_cleanup_after_create_bundle():
    """
    Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/.

    """
    env = reset_env()
    # Install an editable to create a src/ dir.
    args = ['install']
    args.extend(['-e',
                 '%s#egg=pip-test-package' %
                    local_checkout('git+http://github.com/pypa/pip-test-package.git')])
    run_pip(*args)
    build = env.venv_path/"build"
    src = env.venv_path/"src"
    assert not exists(build), "build/ dir still exists: %s" % build
    assert exists(src), "expected src/ dir doesn't exist: %s" % src

    # Make the bundle.
    fspkg = 'file://%s/FSPkg' %join(here, 'packages')
    pkg_lines = textwrap.dedent('''\
            -e %s
            -e %s#egg=initools-dev
            pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    write_file('bundle-req.txt', pkg_lines)
    run_pip('bundle', '-r', 'bundle-req.txt', 'test.pybundle')
    build_bundle = env.scratch_path/"build-bundle"
    src_bundle = env.scratch_path/"src-bundle"
    assert not exists(build_bundle), "build-bundle/ dir still exists: %s" % build_bundle
    assert not exists(src_bundle), "src-bundle/ dir still exists: %s" % src_bundle

    # Make sure previously created src/ from editable still exists
    assert exists(src), "expected src dir doesn't exist: %s" % src
コード例 #3
0
def test_uninstall_from_reqs_file():
    """
    Test uninstall from a requirements file.

    """
    env = reset_env()
    write_file(
        'test-req.txt',
        textwrap.dedent("""\
        -e %s#egg=initools-dev
        # and something else to test out:
        PyLogo<0.4
        """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    result = run_pip('install', '-r', 'test-req.txt')
    write_file(
        'test-req.txt',
        textwrap.dedent("""\
        # -f, -i, and --extra-index-url should all be ignored by uninstall
        -f http://www.example.com
        -i http://www.example.com
        --extra-index-url http://www.example.com

        -e %s#egg=initools-dev
        # and something else to test out:
        PyLogo<0.4
        """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    result2 = run_pip('uninstall', '-r', 'test-req.txt', '-y')
    assert_all_changes(
        result, result2,
        [env.venv / 'build', env.venv / 'src', env.scratch / 'test-req.txt'])
コード例 #4
0
def test_respect_order_in_requirements_file():
    env = reset_env()
    write_file(
        'frameworks-req.txt',
        textwrap.dedent("""\
        parent
        child
        simple
        """))

    find_links = 'file://' + os.path.join(here, 'packages')
    result = run_pip('install', '--no-index', '-f', find_links, '-r',
                     env.scratch_path / 'frameworks-req.txt')

    downloaded = [
        line for line in result.stdout.split('\n')
        if 'Downloading/unpacking' in line
    ]

    assert 'parent' in downloaded[0], 'First download should ' \
            'be "parent" but was "%s"' % downloaded[0]
    assert 'child' in downloaded[1], 'Second download should ' \
            'be "child" but was "%s"' % downloaded[1]
    assert 'simple' in downloaded[2], 'Third download should ' \
            'be "simple" but was "%s"' % downloaded[2]
コード例 #5
0
ファイル: test_freeze.py プロジェクト: ericholscher/pip-1
def test_freeze_basic():
    """
    Some tests of freeze, first we have to install some stuff.  Note that
    the test is a little crude at the end because Python 2.5+ adds egg
    info to the standard library, so stuff like wsgiref will show up in
    the freezing.  (Probably that should be accounted for in pip, but
    currently it is not).

    """
    env = reset_env()
    write_file(
        'initools-req.txt',
        textwrap.dedent("""\
        INITools==0.2
        # and something else to test out:
        MarkupSafe<=0.12
        """))
    result = run_pip('install', '-r', env.scratch_path / 'initools-req.txt')
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: pip freeze
        -- stdout: --------------------
        INITools==0.2
        MarkupSafe==0.12...
        <BLANKLINE>""")
    _check_output(result, expected)
コード例 #6
0
ファイル: test_config.py プロジェクト: slacy/pip
def _test_config_file_override_stack(config_file):
    environ = clear_environ(os.environ.copy())
    environ['PIP_CONFIG_FILE'] = config_file  # set this to make pip load it
    reset_env(environ)
    write_file(
        config_file,
        textwrap.dedent("""\
        [global]
        index-url = http://download.zope.org/ppix
        """))
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Getting page http://download.zope.org/ppix/INITools" in result.stdout
    reset_env(environ)
    write_file(
        config_file,
        textwrap.dedent("""\
        [global]
        index-url = http://download.zope.org/ppix
        [install]
        index-url = http://pypi.appspot.com/
        """))
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
    result = run_pip('install',
                     '-vvv',
                     '--index-url',
                     'http://pypi.python.org/simple',
                     'INITools',
                     expect_error=True)
    assert "Getting page http://download.zope.org/ppix/INITools" not in result.stdout
    assert "Getting page http://pypi.appspot.com/INITools" not in result.stdout
    assert "Getting page http://pypi.python.org/simple/INITools" in result.stdout
コード例 #7
0
def test_multiple_requirements_files():
    """
    Test installing from multiple nested requirements files.

    """
    other_lib_name, other_lib_version = 'anyjson', '0.3'
    env = reset_env()
    write_file(
        'initools-req.txt',
        textwrap.dedent(
            """\
        -e %s@10#egg=INITools-dev
        -r %s-req.txt""" %
            (local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
             other_lib_name)))
    write_file(
        '%s-req.txt' % other_lib_name,
        textwrap.dedent("""\
        %s<=%s
        """ % (other_lib_name, other_lib_version)))
    result = run_pip('install', '-r', env.scratch_path / 'initools-req.txt')
    assert result.files_created[env.site_packages / other_lib_name].dir
    fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion)
    assert result.files_created[env.site_packages / fn].dir
    assert env.venv / 'src' / 'initools' in result.files_created
コード例 #8
0
ファイル: test_upgrade.py プロジェクト: none-da/pip
def test_upgrade_from_reqs_file():
    """
    Upgrade from a requirements file.

    """
    env = reset_env()
    write_file(
        "test-req.txt",
        textwrap.dedent(
            """\
        PyLogo<0.4
        # and something else to test out:
        INITools==0.3
        """
        ),
    )
    install_result = run_pip("install", "-r", env.scratch_path / "test-req.txt")
    write_file(
        "test-req.txt",
        textwrap.dedent(
            """\
        PyLogo
        # and something else to test out:
        INITools
        """
        ),
    )
    run_pip("install", "--upgrade", "-r", env.scratch_path / "test-req.txt")
    uninstall_result = run_pip("uninstall", "-r", env.scratch_path / "test-req.txt", "-y")
    assert_all_changes(install_result, uninstall_result, [env.venv / "build", "cache", env.scratch / "test-req.txt"])
コード例 #9
0
def test_download_should_skip_existing_files():
    """
    It should not download files already existing in the scratch dir
    """
    env = reset_env()

    write_file('test-req.txt', textwrap.dedent("""
        INITools==0.1
        """))

    result = run_pip('install', '-r', env.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True)
    assert Path('scratch')/ 'INITools-0.1.tar.gz' in result.files_created
    assert env.site_packages/ 'initools' not in result.files_created

    # adding second package to test-req.txt
    write_file('test-req.txt', textwrap.dedent("""
        INITools==0.1
        python-openid==2.2.5
        """))

    # only the second package should be downloaded
    result = run_pip('install', '-r', env.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True)
    openid_tarball_prefix = str(Path('scratch')/ 'python-openid-')
    assert any(path.startswith(openid_tarball_prefix) for path in result.files_created)
    assert Path('scratch')/ 'INITools-0.1.tar.gz' not in result.files_created
    assert env.site_packages/ 'initools' not in result.files_created
    assert env.site_packages/ 'openid' not in result.files_created
コード例 #10
0
ファイル: test_freeze.py プロジェクト: genome-vendor/flow-pip
def test_freeze_with_requirement_option():
    """
    Test that new requirements are created correctly with --requirement hints

    """
    reset_env()
    ignores = textwrap.dedent("""\
        # Unchanged requirements below this line
        -r ignore.txt
        --requirement ignore.txt
        -Z ignore
        --always-unzip ignore
        -f http://ignore
        -i http://ignore
        --extra-index-url http://ignore
        --find-links http://ignore
        --index-url http://ignore
        """)
    write_file('hint.txt', textwrap.dedent("""\
        INITools==0.1
        NoExist==4.2
        """) + ignores)
    result = run_pip('install', 'initools==0.2')
    result = run_pip('install', 'MarkupSafe')
    result = run_pip('freeze', '--requirement', 'hint.txt', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: pip freeze --requirement hint.txt
        -- stderr: --------------------
        Requirement file contains NoExist==4.2, but that package is not installed

        -- stdout: --------------------
        INITools==0.2
        """) + ignores + "## The following requirements were added by pip --freeze:..."
    _check_output(result, expected)
コード例 #11
0
def test_create_bundle():
    """
    Test making a bundle.  We'll grab one package from the filesystem
    (the FSPkg dummy package), one from vcs (initools) and one from an
    index (pip itself).

    """
    env = reset_env()
    fspkg = path_to_url2(Path(here) / 'packages' / 'FSPkg')
    run_pip('install', '-e', fspkg)
    pkg_lines = textwrap.dedent(
        '''\
            -e %s
            -e %s#egg=initools-dev
            pip''' %
        (fspkg,
         local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    write_file('bundle-req.txt', pkg_lines)
    # Create a bundle in env.scratch_path/ test.pybundle
    result = run_pip('bundle', '-r', env.scratch_path / 'bundle-req.txt',
                     env.scratch_path / 'test.pybundle')
    bundle = result.files_after.get(join('scratch', 'test.pybundle'), None)
    assert bundle is not None

    files = zipfile.ZipFile(bundle.full).namelist()
    assert 'src/FSPkg/' in files
    assert 'src/initools/' in files
    assert 'build/pip/' in files
コード例 #12
0
ファイル: test_freeze.py プロジェクト: OldBao/pip
def test_freeze_with_requirement_option():
    """
    Test that new requirements are created correctly with --requirement hints

    """
    reset_env()
    ignores = textwrap.dedent("""\
        # Unchanged requirements below this line
        -r ignore.txt
        --requirement ignore.txt
        -Z ignore
        --always-unzip ignore
        -f http://ignore
        -i http://ignore
        --extra-index-url http://ignore
        --find-links http://ignore
        --index-url http://ignore
        """)
    write_file('hint.txt', textwrap.dedent("""\
        INITools==0.1
        NoExist==4.2
        """) + ignores)
    result = run_pip('install', 'initools==0.2')
    result = run_pip('install', 'MarkupSafe')
    result = run_pip('freeze', '--requirement', 'hint.txt', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: pip freeze --requirement hint.txt
        -- stderr: --------------------
        Requirement file contains NoExist==4.2, but that package is not installed

        -- stdout: --------------------
        INITools==0.2
        """) + ignores + "## The following requirements were added by pip --freeze:..."
    _check_output(result, expected)
コード例 #13
0
def test_upgrade_from_reqs_file():
    """
    Upgrade from a requirements file.

    """
    env = reset_env()
    write_file(
        'test-req.txt',
        textwrap.dedent("""\
        PyLogo<0.4
        # and something else to test out:
        INITools==0.3
        """))
    install_result = run_pip('install', '-r',
                             env.scratch_path / 'test-req.txt')
    write_file(
        'test-req.txt',
        textwrap.dedent("""\
        PyLogo
        # and something else to test out:
        INITools
        """))
    run_pip('install', '--upgrade', '-r', env.scratch_path / 'test-req.txt')
    uninstall_result = run_pip('uninstall', '-r',
                               env.scratch_path / 'test-req.txt', '-y')
    assert_all_changes(
        install_result, uninstall_result,
        [env.venv / 'build', 'cache', env.scratch / 'test-req.txt'])
コード例 #14
0
ファイル: test_config.py プロジェクト: MatthewMaker/pip
def _test_config_file_override_stack(config_file):
    environ = clear_environ(os.environ.copy())
    environ["PIP_CONFIG_FILE"] = config_file  # set this to make pip load it
    reset_env(environ)
    write_file(
        config_file,
        textwrap.dedent(
            """\
        [global]
        index-url = http://download.zope.org/ppix
        """
        ),
    )
    result = run_pip("install", "-vvv", "INITools", expect_error=True)
    assert "Getting page http://download.zope.org/ppix/INITools" in result.stdout
    reset_env(environ)
    write_file(
        config_file,
        textwrap.dedent(
            """\
        [global]
        index-url = http://download.zope.org/ppix
        [install]
        index-url = http://pypi.appspot.com/
        """
        ),
    )
    result = run_pip("install", "-vvv", "INITools", expect_error=True)
    assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
    result = run_pip("install", "-vvv", "--index-url", "http://pypi.python.org/simple", "INITools", expect_error=True)
    assert "Getting page http://download.zope.org/ppix/INITools" not in result.stdout
    assert "Getting page http://pypi.appspot.com/INITools" not in result.stdout
    assert "Getting page http://pypi.python.org/simple/INITools" in result.stdout
コード例 #15
0
ファイル: test_uninstall.py プロジェクト: AndreaCrotti/pip
def test_uninstall_from_reqs_file():
    """
    Test uninstall from a requirements file.

    """
    env = reset_env()
    write_file('test-req.txt', textwrap.dedent("""\
        -e %s#egg=initools-dev
        # and something else to test out:
        PyLogo<0.4
        """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    result = run_pip('install', '-r', 'test-req.txt')
    write_file('test-req.txt', textwrap.dedent("""\
        # -f, -i, and --extra-index-url should all be ignored by uninstall
        -f http://www.example.com
        -i http://www.example.com
        --extra-index-url http://www.example.com

        -e %s#egg=initools-dev
        # and something else to test out:
        PyLogo<0.4
        """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    result2 = run_pip('uninstall', '-r', 'test-req.txt', '-y')
    assert_all_changes(
        result, result2, [env.venv/'build', env.venv/'src', env.scratch/'test-req.txt'])
コード例 #16
0
def test_schema_check_in_requirements_file():
    """
    Test installing from a requirements file with an invalid vcs schema..

    """
    env = reset_env()
    write_file('file-egg-req.txt', textwrap.dedent("""\
        git://github.com/alex/django-fixture-generator.git#egg=fixture_generator
        """))
    assert_raises(AssertionError, run_pip, 'install', '-vvv', '-r', env.scratch_path / 'file-egg-req.txt')
コード例 #17
0
ファイル: test_basic.py プロジェクト: qiemem/pip
def test_install_folder_using_slash_in_the_end():
    r"""
    Test installing a folder using pip install foldername/ or foldername\
    """
    env = reset_env()
    mkdir('mock')
    pkg_path = env.scratch_path / 'mock'
    write_file('setup.py', mock100_setup_py, pkg_path)
    result = run_pip('install', 'mock' + os.path.sep)
    egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
    assert egg_folder in result.files_created, str(result)
コード例 #18
0
def test_install_folder_using_dot_slash():
    """
    Test installing a folder using pip install ./foldername
    """
    env = reset_env()
    mkdir("mock")
    pkg_path = env.scratch_path / "mock"
    write_file("setup.py", mock100_setup_py, pkg_path)
    result = run_pip("install", "./mock")
    egg_folder = env.site_packages / "mock-100.1-py%s.egg-info" % pyversion
    assert egg_folder in result.files_created, str(result)
コード例 #19
0
ファイル: test_basic.py プロジェクト: saxix/pip
def test_install_folder_using_slash_in_the_end():
    r"""
    Test installing a folder using pip install foldername/ or foldername\
    """
    env = reset_env()
    mkdir('mock')
    pkg_path = env.scratch_path/'mock'
    write_file('setup.py', mock100_setup_py, pkg_path)
    result = run_pip('install', 'mock' + os.path.sep)
    egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
    assert egg_folder in result.files_created, str(result)
コード例 #20
0
def test_install_folder_using_relative_path():
    """
    Test installing a folder using pip install folder1/folder2
    """
    env = reset_env()
    mkdir("initools")
    mkdir(Path("initools") / "mock")
    pkg_path = env.scratch_path / "initools" / "mock"
    write_file("setup.py", mock100_setup_py, pkg_path)
    result = run_pip("install", Path("initools") / "mock")
    egg_folder = env.site_packages / "mock-100.1-py%s.egg-info" % pyversion
    assert egg_folder in result.files_created, str(result)
コード例 #21
0
def test_single_download_from_requirements_file():
    """
    It should support download (in the scratch path) from PyPi from a requirements file
    """

    env = reset_env()
    write_file('test-req.txt', textwrap.dedent("""
        INITools==0.1
        """))
    result = run_pip('install', '-r', env.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True)
    assert Path('scratch')/ 'INITools-0.1.tar.gz' in result.files_created
    assert env.site_packages/ 'initools' not in result.files_created
コード例 #22
0
ファイル: test_download.py プロジェクト: OldBao/pip
def test_single_download_from_requirements_file():
    """
    It should support download (in the scratch path) from PyPi from a requirements file
    """

    env = reset_env()
    write_file('test-req.txt', textwrap.dedent("""
        INITools==0.1
        """))
    result = run_pip('install', '-r', env.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True)
    assert Path('scratch')/ 'INITools-0.1.tar.gz' in result.files_created
    assert env.site_packages/ 'initools' not in result.files_created
コード例 #23
0
ファイル: test_basic.py プロジェクト: saxix/pip
def test_install_folder_using_relative_path():
    """
    Test installing a folder using pip install folder1/folder2
    """
    env = reset_env()
    mkdir('initools')
    mkdir(Path('initools')/'mock')
    pkg_path = env.scratch_path/'initools'/'mock'
    write_file('setup.py', mock100_setup_py, pkg_path)
    result = run_pip('install', Path('initools')/'mock')
    egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
    assert egg_folder in result.files_created, str(result)
コード例 #24
0
def _change_test_package_submodule(env, submodule_path):
    write_file(submodule_path / 'testfile', 'this is a changed file')
    write_file(submodule_path / 'testfile2', 'this is an added file')
    env.run('git', 'add', '.', cwd=submodule_path)
    env.run('git',
            'commit',
            '-q',
            '--author',
            'Pip <*****@*****.**>',
            '-am',
            'submodule change',
            cwd=submodule_path)
コード例 #25
0
ファイル: test_basic.py プロジェクト: qiemem/pip
def test_install_folder_using_relative_path():
    """
    Test installing a folder using pip install folder1/folder2
    """
    env = reset_env()
    mkdir('initools')
    mkdir(Path('initools') / 'mock')
    pkg_path = env.scratch_path / 'initools' / 'mock'
    write_file('setup.py', mock100_setup_py, pkg_path)
    result = run_pip('install', Path('initools') / 'mock')
    egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
    assert egg_folder in result.files_created, str(result)
コード例 #26
0
def test_relative_requirements_file():
    """
    Test installing from a requirements file with a relative path with an egg= definition..

    """
    url = path_to_url(os.path.join(here, 'packages', '..', 'packages', 'FSPkg')) + '#egg=FSPkg'
    env = reset_env()
    write_file('file-egg-req.txt', textwrap.dedent("""\
        %s
        """ % url))
    result = run_pip('install', '-vvv', '-r', env.scratch_path / 'file-egg-req.txt')
    assert (env.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion) in result.files_created, str(result)
    assert (env.site_packages/'fspkg') in result.files_created, str(result.stdout)
コード例 #27
0
ファイル: test_basic.py プロジェクト: PJMODOS/pip
def test_find_command_folder_in_path():
    """
    If a folder named e.g. 'git' is in PATH, and find_command is looking for
    the 'git' executable, it should not match the folder, but rather keep
    looking.
    """
    env = reset_env()
    mkdir('path_one'); path_one = env.scratch_path/'path_one'
    mkdir(path_one/'foo')
    mkdir('path_two'); path_two = env.scratch_path/'path_two'
    write_file(path_two/'foo', '# nothing')
    found_path = find_command('foo', map(str, [path_one, path_two]))
    assert found_path == path_two/'foo'
コード例 #28
0
def test_relative_requirements_file():
    """
    Test installing from a requirements file with a relative path with an egg= definition..

    """
    url = path_to_url(os.path.join(here, 'packages', '..', 'packages', 'FSPkg')) + '#egg=FSPkg'
    env = reset_env()
    write_file('file-egg-req.txt', textwrap.dedent("""\
        %s
        """ % url))
    result = run_pip('install', '-vvv', '-r', env.scratch_path / 'file-egg-req.txt')
    assert (env.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion) in result.files_created, str(result)
    assert (env.site_packages/'fspkg') in result.files_created, str(result.stdout)
コード例 #29
0
ファイル: test_basic.py プロジェクト: qiemem/pip
def test_find_command_folder_in_path():
    """
    If a folder named e.g. 'git' is in PATH, and find_command is looking for
    the 'git' executable, it should not match the folder, but rather keep
    looking.
    """
    env = reset_env()
    mkdir('path_one')
    path_one = env.scratch_path / 'path_one'
    mkdir(path_one / 'foo')
    mkdir('path_two')
    path_two = env.scratch_path / 'path_two'
    write_file(path_two / 'foo', '# nothing')
    found_path = find_command('foo', map(str, [path_one, path_two]))
    assert found_path == path_two / 'foo'
コード例 #30
0
def test_find_command_folder_in_path():
    """
    If a folder named e.g. 'git' is in PATH, and find_command is looking for
    the 'git' executable, it should not match the folder, but rather keep
    looking.
    """
    env = reset_env()
    mkdir("path_one")
    path_one = env.scratch_path / "path_one"
    mkdir(path_one / "foo")
    mkdir("path_two")
    path_two = env.scratch_path / "path_two"
    write_file(path_two / "foo", "# nothing")
    found_path = find_command("foo", map(str, [path_one, path_two]))
    assert found_path == path_two / "foo"
コード例 #31
0
ファイル: test_find_links.py プロジェクト: AndreaCrotti/pip
def test_find_links_requirements_file_relative_path():
    """Test find-links as a relative path to a reqs file."""
    e = reset_env()
    write_file('test-req.txt', textwrap.dedent("""
        --no-index
        --find-links=../../../packages/
        parent==0.1
        """))
    result = run_pip(
        'install',
        '-r',
        e.scratch_path / "test-req.txt",
        cwd=here)
    egg_info_folder = e.site_packages / 'parent-0.1-py%s.egg-info' % pyversion
    initools_folder = e.site_packages / 'parent'
    assert egg_info_folder in result.files_created, str(result)
    assert initools_folder in result.files_created, str(result)
コード例 #32
0
def test_respect_order_in_requirements_file():
    env = reset_env()
    write_file('frameworks-req.txt', textwrap.dedent("""\
        bidict
        ordereddict
        initools
        """))
    result = run_pip('install', '-r', env.scratch_path / 'frameworks-req.txt')
    downloaded = [line for line in result.stdout.split('\n')
                  if 'Downloading/unpacking' in line]

    assert 'bidict' in downloaded[0], 'First download should ' \
            'be "bidict" but was "%s"' % downloaded[0]
    assert 'ordereddict' in downloaded[1], 'Second download should ' \
            'be "ordereddict" but was "%s"' % downloaded[1]
    assert 'initools' in downloaded[2], 'Third download should ' \
            'be "initools" but was "%s"' % downloaded[2]
コード例 #33
0
def test_respect_order_in_requirements_file():
    env = reset_env()
    write_file('frameworks-req.txt', textwrap.dedent("""\
        bidict
        ordereddict
        initools
        """))
    result = run_pip('install', '-r', env.scratch_path / 'frameworks-req.txt')
    downloaded = [line for line in result.stdout.split('\n')
                  if 'Downloading/unpacking' in line]

    assert 'bidict' in downloaded[0], 'First download should ' \
            'be "bidict" but was "%s"' % downloaded[0]
    assert 'ordereddict' in downloaded[1], 'Second download should ' \
            'be "ordereddict" but was "%s"' % downloaded[1]
    assert 'initools' in downloaded[2], 'Third download should ' \
            'be "initools" but was "%s"' % downloaded[2]
コード例 #34
0
def test_requirements_file():
    """
    Test installing from a requirements file.

    """
    other_lib_name, other_lib_version = 'anyjson', '0.3'
    env = reset_env()
    write_file('initools-req.txt', textwrap.dedent("""\
        INITools==0.2
        # and something else to test out:
        %s<=%s
        """ % (other_lib_name, other_lib_version)))
    result = run_pip('install', '-r', env.scratch_path / 'initools-req.txt')
    assert env.site_packages/'INITools-0.2-py%s.egg-info' % pyversion in result.files_created
    assert env.site_packages/'initools' in result.files_created
    assert result.files_created[env.site_packages/other_lib_name].dir
    fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion)
    assert result.files_created[env.site_packages/fn].dir
コード例 #35
0
ファイル: test_config.py プロジェクト: genome-vendor/flow-pip
def _test_env_vars_override_config_file(config_file):
    environ = clear_environ(os.environ.copy())
    environ['PIP_CONFIG_FILE'] = config_file # set this to make pip load it
    reset_env(environ)
    # It's important that we test this particular config value ('no-index')
    # because their is/was a bug which only shows up in cases in which
    # 'config-item' and 'config_item' hash to the same value modulo the size
    # of the config dictionary.
    write_file(config_file, textwrap.dedent("""\
        [global]
        no-index = 1
        """))
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "DistributionNotFound: No distributions at all found for INITools" in result.stdout
    environ['PIP_NO_INDEX'] = '0'
    reset_env(environ)
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Successfully installed INITools" in result.stdout
コード例 #36
0
def test_requirements_file():
    """
    Test installing from a requirements file.

    """
    other_lib_name, other_lib_version = 'anyjson', '0.3'
    env = reset_env()
    write_file('initools-req.txt', textwrap.dedent("""\
        INITools==0.2
        # and something else to test out:
        %s<=%s
        """ % (other_lib_name, other_lib_version)))
    result = run_pip('install', '-r', env.scratch_path / 'initools-req.txt')
    assert env.site_packages/'INITools-0.2-py%s.egg-info' % pyversion in result.files_created
    assert env.site_packages/'initools' in result.files_created
    assert result.files_created[env.site_packages/other_lib_name].dir
    fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion)
    assert result.files_created[env.site_packages/fn].dir
コード例 #37
0
def test_find_links_requirements_file_relative_path():
    """Test find-links as a relative path to a reqs file."""
    e = reset_env()
    write_file(
        'test-req.txt',
        textwrap.dedent("""
        --no-index
        --find-links=../../../packages/
        parent==0.1
        """))
    result = run_pip('install',
                     '-r',
                     e.scratch_path / "test-req.txt",
                     cwd=here)
    egg_info_folder = e.site_packages / 'parent-0.1-py%s.egg-info' % pyversion
    initools_folder = e.site_packages / 'parent'
    assert egg_info_folder in result.files_created, str(result)
    assert initools_folder in result.files_created, str(result)
コード例 #38
0
def test_multiple_requirements_files():
    """
    Test installing from multiple nested requirements files.

    """
    other_lib_name, other_lib_version = 'anyjson', '0.3'
    env = reset_env()
    write_file('initools-req.txt', textwrap.dedent("""\
        -e %s@10#egg=INITools-dev
        -r %s-req.txt""" % (local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
                            other_lib_name)))
    write_file('%s-req.txt' % other_lib_name, textwrap.dedent("""\
        %s<=%s
        """ % (other_lib_name, other_lib_version)))
    result = run_pip('install', '-r', env.scratch_path / 'initools-req.txt')
    assert result.files_created[env.site_packages/other_lib_name].dir
    fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion)
    assert result.files_created[env.site_packages/fn].dir
    assert env.venv/'src'/'initools' in result.files_created
コード例 #39
0
ファイル: test_upgrade.py プロジェクト: AndreaCrotti/pip
def test_upgrade_from_reqs_file():
    """
    Upgrade from a requirements file.

    """
    env = reset_env()
    write_file('test-req.txt', textwrap.dedent("""\
        PyLogo<0.4
        # and something else to test out:
        INITools==0.3
        """))
    install_result = run_pip('install', '-r', env.scratch_path/ 'test-req.txt')
    write_file('test-req.txt', textwrap.dedent("""\
        PyLogo
        # and something else to test out:
        INITools
        """))
    run_pip('install', '--upgrade', '-r', env.scratch_path/ 'test-req.txt')
    uninstall_result = run_pip('uninstall', '-r', env.scratch_path/ 'test-req.txt', '-y')
    assert_all_changes(install_result, uninstall_result, [env.venv/'build', 'cache', env.scratch/'test-req.txt'])
コード例 #40
0
ファイル: test_requirements.py プロジェクト: AndreaCrotti/pip
def test_respect_order_in_requirements_file():
    env = reset_env()
    write_file('frameworks-req.txt', textwrap.dedent("""\
        parent
        child
        simple
        """))

    find_links = 'file://' + os.path.join(here, 'packages')
    result = run_pip('install', '--no-index', '-f', find_links, '-r', env.scratch_path / 'frameworks-req.txt')

    downloaded = [line for line in result.stdout.split('\n')
                  if 'Downloading/unpacking' in line]

    assert 'parent' in downloaded[0], 'First download should ' \
            'be "parent" but was "%s"' % downloaded[0]
    assert 'child' in downloaded[1], 'Second download should ' \
            'be "child" but was "%s"' % downloaded[1]
    assert 'simple' in downloaded[2], 'Third download should ' \
            'be "simple" but was "%s"' % downloaded[2]
コード例 #41
0
def test_cleanup_after_create_bundle():
    """
    Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/.

    """
    env = reset_env()
    # Install an editable to create a src/ dir.
    args = ['install']
    args.extend([
        '-e',
        '%s#egg=pip-test-package' %
        local_checkout('git+http://github.com/pypa/pip-test-package.git')
    ])
    run_pip(*args)
    build = env.venv_path / "build"
    src = env.venv_path / "src"
    assert not exists(build), "build/ dir still exists: %s" % build
    assert exists(src), "expected src/ dir doesn't exist: %s" % src

    # Make the bundle.
    fspkg = 'file://%s/FSPkg' % join(here, 'packages')
    pkg_lines = textwrap.dedent(
        '''\
            -e %s
            -e %s#egg=initools-dev
            pip''' %
        (fspkg,
         local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    write_file('bundle-req.txt', pkg_lines)
    run_pip('bundle', '-r', 'bundle-req.txt', 'test.pybundle')
    build_bundle = env.scratch_path / "build-bundle"
    src_bundle = env.scratch_path / "src-bundle"
    assert not exists(
        build_bundle), "build-bundle/ dir still exists: %s" % build_bundle
    assert not exists(
        src_bundle), "src-bundle/ dir still exists: %s" % src_bundle
    env.assert_no_temp()

    # Make sure previously created src/ from editable still exists
    assert exists(src), "expected src dir doesn't exist: %s" % src
コード例 #42
0
ファイル: test_list.py プロジェクト: saxix/pip
def test_outdated_flag():
    """
    Test the behavior of --outdated flag in the list command

    """
    env = reset_env()
    total_re = re.compile('LATEST: +([0-9.\w]+)')
    write_file('req.txt', textwrap.dedent("""\
        INITools==0.2
        # and something else to test out:
        mock==0.7.0
        -e git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package
    """))
    run_pip('install', '-r', env.scratch_path/'req.txt')
    result = run_pip('search', 'mock')
    mock_ver = total_re.search(str(result)).group(1)
    result = run_pip('search', 'INITools')
    initools_ver = total_re.search(str(result)).group(1)
    result = run_pip('list', '--outdated', expect_stderr=True)
    assert 'INITools (Current: 0.2 Latest: %s)' % initools_ver in result.stdout, str(result)
    assert 'pip-test-package' not in result.stdout #editables excluded
    assert 'mock (Current: 0.7.0 Latest: %s)' % mock_ver in result.stdout, str(result)
コード例 #43
0
ファイル: test_uninstall.py プロジェクト: rafaelcaricio/pip
def test_uninstall_from_reqs_file():
    """
    Test uninstall from a requirements file.

    """
    env = reset_env()
    write_file(
        "test-req.txt",
        textwrap.dedent(
            """\
        -e %s#egg=initools-dev
        # and something else to test out:
        PyLogo<0.4
        """
            % local_checkout("svn+http://svn.colorstudy.com/INITools/trunk")
        ),
    )
    result = run_pip("install", "-r", "test-req.txt")
    write_file(
        "test-req.txt",
        textwrap.dedent(
            """\
        # -f, -i, and --extra-index-url should all be ignored by uninstall
        -f http://www.example.com
        -i http://www.example.com
        --extra-index-url http://www.example.com

        -e %s#egg=initools-dev
        # and something else to test out:
        PyLogo<0.4
        """
            % local_checkout("svn+http://svn.colorstudy.com/INITools/trunk")
        ),
    )
    result2 = run_pip("uninstall", "-r", "test-req.txt", "-y")
    assert_all_changes(result, result2, [env.venv / "build", env.venv / "src", env.scratch / "test-req.txt"])
コード例 #44
0
ファイル: test_bundle.py プロジェクト: AndreaCrotti/pip
def test_create_bundle():
    """
    Test making a bundle.  We'll grab one package from the filesystem
    (the FSPkg dummy package), one from vcs (initools) and one from an
    index (pip itself).

    """
    env = reset_env()
    fspkg = path_to_url2(Path(here)/'packages'/'FSPkg')
    run_pip('install', '-e', fspkg)
    pkg_lines = textwrap.dedent('''\
            -e %s
            -e %s#egg=initools-dev
            pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    write_file('bundle-req.txt', pkg_lines)
    # Create a bundle in env.scratch_path/ test.pybundle
    result = run_pip('bundle', '-r', env.scratch_path/ 'bundle-req.txt', env.scratch_path/ 'test.pybundle')
    bundle = result.files_after.get(join('scratch', 'test.pybundle'), None)
    assert bundle is not None

    files = zipfile.ZipFile(bundle.full).namelist()
    assert 'src/FSPkg/' in files
    assert 'src/initools/' in files
    assert 'build/pip/' in files
コード例 #45
0
ファイル: test_freeze.py プロジェクト: PJMODOS/pip
def test_freeze_basic():
    """
    Some tests of freeze, first we have to install some stuff.  Note that
    the test is a little crude at the end because Python 2.5+ adds egg
    info to the standard library, so stuff like wsgiref will show up in
    the freezing.  (Probably that should be accounted for in pip, but
    currently it is not).

    """
    env = reset_env()
    write_file('initools-req.txt', textwrap.dedent("""\
        INITools==0.2
        # and something else to test out:
        MarkupSafe<=0.12
        """))
    result = run_pip('install', '-r', env.scratch_path/'initools-req.txt')
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: pip freeze
        -- stdout: --------------------
        INITools==0.2
        MarkupSafe==0.12...
        <BLANKLINE>""")
    _check_output(result, expected)
コード例 #46
0
def _create_test_package_with_submodule(env):
    mkdir('version_pkg')
    version_pkg_path = env.scratch_path / 'version_pkg'
    mkdir(version_pkg_path / 'testpkg')
    pkg_path = version_pkg_path / 'testpkg'

    write_file('__init__.py', '# hello there', pkg_path)
    write_file(
        'version_pkg.py',
        textwrap.dedent('''\
                                def main():
                                    print('0.1')
                                '''), pkg_path)
    write_file(
        'setup.py',
        textwrap.dedent('''\
                        from setuptools import setup, find_packages
                        setup(name='version_pkg',
                              version='0.1',
                              packages=find_packages(),
                             )
                        '''), version_pkg_path)
    env.run('git', 'init', cwd=version_pkg_path, expect_error=True)
    env.run('git', 'add', '.', cwd=version_pkg_path, expect_error=True)
    env.run('git',
            'commit',
            '-q',
            '--author',
            'Pip <*****@*****.**>',
            '-am',
            'initial version',
            cwd=version_pkg_path,
            expect_error=True)

    submodule_path = _create_test_package_submodule(env)

    env.run('git',
            'submodule',
            'add',
            submodule_path,
            'testpkg/static',
            cwd=version_pkg_path,
            expect_error=True)
    env.run('git',
            'commit',
            '-q',
            '--author',
            'Pip <*****@*****.**>',
            '-am',
            'initial version w submodule',
            cwd=version_pkg_path,
            expect_error=True)

    return version_pkg_path, submodule_path
コード例 #47
0
def _create_test_package_with_submodule(env):
    mkdir('version_pkg')
    version_pkg_path = env.scratch_path/'version_pkg'
    mkdir(version_pkg_path/'testpkg')
    pkg_path = version_pkg_path/'testpkg'

    write_file('__init__.py', '# hello there', pkg_path)
    write_file('version_pkg.py', textwrap.dedent('''\
                                def main():
                                    print('0.1')
                                '''), pkg_path)
    write_file('setup.py', textwrap.dedent('''\
                        from setuptools import setup, find_packages
                        setup(name='version_pkg',
                              version='0.1',
                              packages=find_packages(),
                             )
                        '''), version_pkg_path)
    env.run('git', 'init', cwd=version_pkg_path, expect_error=True)
    env.run('git', 'add', '.', cwd=version_pkg_path, expect_error=True)
    env.run('git', 'commit', '-q',
            '--author', 'Pip <*****@*****.**>',
            '-am', 'initial version', cwd=version_pkg_path,
            expect_error=True)


    submodule_path = _create_test_package_submodule(env)

    env.run('git', 'submodule', 'add', submodule_path, 'testpkg/static', cwd=version_pkg_path,
            expect_error=True)
    env.run('git', 'commit', '-q',
            '--author', 'Pip <*****@*****.**>',
            '-am', 'initial version w submodule', cwd=version_pkg_path,
            expect_error=True)


    return version_pkg_path, submodule_path