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)
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"
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)
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)
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)
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) result = run_pip('install', '-e', '%s#egg=virtualenv' % local_checkout('hg+http://bitbucket.org/ianb/virtualenv'), '--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_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)
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) result = run_pip( 'install', '-e', '%s#egg=virtualenv' % local_checkout('hg+http://bitbucket.org/ianb/virtualenv'), '--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"
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_editable_to_custom_path(): """ Test downloading an editable using a relative custom src folder. """ reset_env() mkdir('customdl') result = run_pip('install', '-e', 'svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev', '--src', 'customsrc', '--download', 'customdl', expect_error=True) 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' assert [filename for filename in result.files_created.keys() if filename.startswith(customdl)]
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_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
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') from pip.util import find_command found_path = find_command('foo', map(str, [path_one, path_two])) assert found_path == path_two/'foo'
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') from pip.util import find_command found_path = find_command('foo', map(str, [path_one, path_two])) assert found_path == path_two / 'foo'