Пример #1
0
def test_install_package_with_same_name_in_curdir():
    """
    Test installing a package with the same name of a local folder
    """
    env = reset_env()
    mkdir('mock==0.6')
    result = run_pip('install', 'mock==0.6')
    egg_folder = env.site_packages / 'mock-0.6.0-py%s.egg-info' % pyversion
    assert egg_folder in result.files_created, str(result)
Пример #2
0
def test_install_package_with_same_name_in_curdir():
    """
    Test installing a package with the same name of a local folder
    """
    env = reset_env()
    mkdir('mock==0.6')
    result = run_pip('install', 'mock==0.6')
    egg_folder = env.site_packages / 'mock-0.6.0-py%s.egg-info' % pyversion
    assert egg_folder in result.files_created, str(result)
Пример #3
0
def test_no_install_and_download_should_not_leave_build_dir():
    """
    It should remove build/ dir if it was pip that created
    """
    env = reset_env()
    mkdir('downloaded_packages')
    assert not os.path.exists(env.venv_path/'/build')
    result = run_pip('install', '--no-install', 'INITools==0.2', '-d', 'downloaded_packages')
    assert Path('scratch')/'downloaded_packages/build' not in result.files_created, 'pip should not leave build/ dir'
    assert not os.path.exists(env.venv_path/'/build'), "build/ dir should be deleted"
Пример #4
0
def _create_test_package_submodule(env):
    mkdir('version_pkg_submodule')
    submodule_path = env.scratch_path/'version_pkg_submodule'
    env.run('touch', 'testfile', cwd=submodule_path)
    env.run('git', 'init', cwd=submodule_path)
    env.run('git', 'add', '.', cwd=submodule_path)
    env.run('git', 'commit', '-q',
            '--author', 'Pip <*****@*****.**>',
            '-am', 'initial version / submodule', cwd=submodule_path)
    return submodule_path
Пример #5
0
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)
Пример #6
0
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)
Пример #7
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)
Пример #8
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
Пример #9
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)
Пример #10
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)
Пример #11
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)
Пример #12
0
def test_install_using_install_option_and_editable():
    """
    Test installing a tool using -e and --install-option
    """
    env = reset_env()
    folder = 'script_folder'
    mkdir(folder)
    url = 'git+git://github.com/pypa/virtualenv'
    result = run_pip('install', '-e',
                     '%s#egg=virtualenv' % local_checkout(url),
                     '--install-option=--script-dir=%s' % folder)
    virtualenv_bin = env.venv / 'src' / 'virtualenv' / folder / 'virtualenv' + env.exe
    assert virtualenv_bin in result.files_created
Пример #13
0
def test_install_using_install_option_and_editable():
    """
    Test installing a tool using -e and --install-option
    """
    env = reset_env()
    folder = "script_folder"
    mkdir(folder)
    url = "git+git://github.com/pypa/virtualenv"
    result = run_pip(
        "install", "-e", "%s#egg=virtualenv" % local_checkout(url), "--install-option=--script-dir=%s" % folder
    )
    virtualenv_bin = env.venv / "src" / "virtualenv" / folder / "virtualenv" + env.exe
    assert virtualenv_bin in result.files_created
Пример #14
0
def test_install_using_install_option_and_editable():
    """
    Test installing a tool using -e and --install-option
    """
    env = reset_env()
    folder = 'script_folder'
    mkdir(folder)
    url = 'git+git://github.com/pypa/virtualenv'
    result = run_pip('install', '-e', '%s#egg=virtualenv' %
                      local_checkout(url),
                     '--install-option=--script-dir=%s' % folder)
    virtualenv_bin = env.venv/'src'/'virtualenv'/folder/'virtualenv'+env.exe
    assert virtualenv_bin in result.files_created
def test_no_install_and_download_should_not_leave_build_dir():
    """
    It should remove build/ dir if it was pip that created
    """
    env = reset_env()
    mkdir('downloaded_packages')
    assert not os.path.exists(env.venv_path / '/build')
    result = run_pip('install', '--no-install', 'INITools==0.2', '-d',
                     'downloaded_packages')
    assert Path(
        'scratch'
    ) / 'downloaded_packages/build' not in result.files_created, 'pip should not leave build/ dir'
    assert not os.path.exists(
        env.venv_path / '/build'), "build/ dir should be deleted"
Пример #16
0
def _create_test_package_submodule(env):
    mkdir('version_pkg_submodule')
    submodule_path = env.scratch_path / 'version_pkg_submodule'
    env.run('touch', 'testfile', cwd=submodule_path)
    env.run('git', 'init', cwd=submodule_path)
    env.run('git', 'add', '.', cwd=submodule_path)
    env.run('git',
            'commit',
            '-q',
            '--author',
            'Pip <*****@*****.**>',
            '-am',
            'initial version / submodule',
            cwd=submodule_path)
    return submodule_path
Пример #17
0
def test_download_should_not_delete_existing_build_dir():
    """
    It should not delete build/ if existing before run the command
    """
    env = reset_env()
    mkdir(env.venv_path/'build')
    f = open(env.venv_path/'build'/'somefile.txt', 'w')
    f.write('I am not empty!')
    f.close()
    run_pip('install', '--no-install', 'INITools==0.2', '-d', '.')
    f = open(env.venv_path/'build'/'somefile.txt')
    content = f.read()
    f.close()
    assert os.path.exists(env.venv_path/'build'), "build/ should be left if it exists before pip run"
    assert content == 'I am not empty!', "it should not affect build/ and its content"
    assert ['somefile.txt'] == os.listdir(env.venv_path/'build')
def test_download_should_not_delete_existing_build_dir():
    """
    It should not delete build/ if existing before run the command
    """
    env = reset_env()
    mkdir(env.venv_path / 'build')
    f = open(env.venv_path / 'build' / 'somefile.txt', 'w')
    f.write('I am not empty!')
    f.close()
    run_pip('install', '--no-install', 'INITools==0.2', '-d', '.')
    f = open(env.venv_path / 'build' / 'somefile.txt')
    content = f.read()
    f.close()
    assert os.path.exists(
        env.venv_path /
        'build'), "build/ should be left if it exists before pip run"
    assert content == 'I am not empty!', "it should not affect build/ and its content"
    assert ['somefile.txt'] == os.listdir(env.venv_path / 'build')
Пример #19
0
def test_download_editable_to_custom_path():
    """
    Test downloading an editable using a relative custom src folder.
    """
    reset_env()
    mkdir('customdl')
    result = run_pip('install',
                     '-e',
                     '%s#egg=initools-dev' %
                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
                     '--src',
                     'customsrc',
                     '--download',
                     'customdl')
    customsrc = Path('scratch')/'customsrc'/'initools'
    assert customsrc in result.files_created, sorted(result.files_created.keys())
    assert customsrc/'setup.py' in result.files_created, sorted(result.files_created.keys())

    customdl = Path('scratch')/'customdl'/'initools'
    customdl_files_created = [filename for filename in result.files_created
                                           if filename.startswith(customdl)]
    assert customdl_files_created
Пример #20
0
def test_download_editable_to_custom_path():
    """
    Test downloading an editable using a relative custom src folder.
    """
    reset_env()
    mkdir("customdl")
    result = run_pip(
        "install",
        "-e",
        "%s#egg=initools-dev" % local_checkout("svn+http://svn.colorstudy.com/INITools/trunk"),
        "--src",
        "customsrc",
        "--download",
        "customdl",
    )
    customsrc = Path("scratch") / "customsrc" / "initools"
    assert customsrc in result.files_created, sorted(result.files_created.keys())
    assert customsrc / "setup.py" in result.files_created, sorted(result.files_created.keys())

    customdl = Path("scratch") / "customdl" / "initools"
    customdl_files_created = [filename for filename in result.files_created if filename.startswith(customdl)]
    assert customdl_files_created
Пример #21
0
def test_download_editable_to_custom_path():
    """
    Test downloading an editable using a relative custom src folder.
    """
    reset_env()
    mkdir('customdl')
    result = run_pip(
        'install', '-e', '%s#egg=initools-dev' %
        local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
        '--src', 'customsrc', '--download', 'customdl')
    customsrc = Path('scratch') / 'customsrc' / 'initools'
    assert customsrc in result.files_created, sorted(
        result.files_created.keys())
    assert customsrc / 'setup.py' in result.files_created, sorted(
        result.files_created.keys())

    customdl = Path('scratch') / 'customdl' / 'initools'
    customdl_files_created = [
        filename for filename in result.files_created
        if filename.startswith(customdl)
    ]
    assert customdl_files_created
Пример #22
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
Пример #23
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'
Пример #24
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"
Пример #25
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'