diff --git a/pip/__init__.py b/pip/__init__.py index f8e610c93..dc2273969 100755 --- a/pip/__init__.py +++ b/pip/__init__.py @@ -109,7 +109,7 @@ def create_main_parser(): pip_pkg_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) parser.version = 'pip %s from %s (python %s)' % ( - __version__, pip_pkg_dir, sys.version[:3]) + __version__, pip_pkg_dir, sys.version[:3]) # add the general options gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, parser) @@ -247,8 +247,10 @@ class FrozenRequirement(object): if ver_match or date_match: svn_backend = vcs.get_backend('svn') if svn_backend: - svn_location = svn_backend( - ).get_location(dist, dependency_links) + svn_location = svn_backend().get_location( + dist, + dependency_links, + ) if not svn_location: logger.warn( 'Warning: cannot find svn location for %s' % req) diff --git a/pip/cmdoptions.py b/pip/cmdoptions.py index 703f731b0..0bee7912c 100644 --- a/pip/cmdoptions.py +++ b/pip/cmdoptions.py @@ -357,8 +357,8 @@ general_group = { skip_requirements_regex, exists_action, cert, - ] - } + ] +} index_group = { 'name': 'Package Index Options', @@ -375,5 +375,5 @@ index_group = { allow_unsafe, no_allow_unsafe, process_dependency_links, - ] - } + ] +} diff --git a/pip/commands/install.py b/pip/commands/install.py index 3f740e38c..21bb10762 100644 --- a/pip/commands/install.py +++ b/pip/commands/install.py @@ -357,7 +357,7 @@ class InstallCommand(Command): for item in os.listdir(lib_dir): shutil.move( os.path.join(lib_dir, item), - os.path.join(options.target_dir, item) - ) + os.path.join(options.target_dir, item), + ) shutil.rmtree(temp_target_dir) return requirement_set diff --git a/pip/download.py b/pip/download.py index 7458e48e9..fd64b46ab 100644 --- a/pip/download.py +++ b/pip/download.py @@ -521,7 +521,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None, already_cached = ( os.path.exists(cache_file) and os.path.exists(cache_content_type_file) - ) + ) if not os.path.isdir(download_cache): create_download_cache_folder(download_cache) @@ -545,7 +545,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None, logger.warn( 'Previously-downloaded file %s has bad hash, ' 're-downloading.' % temp_location - ) + ) temp_location = None os.unlink(already_downloaded) already_downloaded = None @@ -564,7 +564,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None, logger.warn( 'Cached file %s has bad hash, ' 're-downloading.' % temp_location - ) + ) temp_location = None os.unlink(cache_file) os.unlink(cache_content_type_file) @@ -654,7 +654,7 @@ def unpack_file_url(link, location, download_dir=None): logger.warn( 'Previously-downloaded file %s has bad hash, ' 're-downloading.' % link_path - ) + ) os.unlink(download_path) else: already_downloaded = True diff --git a/pip/index.py b/pip/index.py index 038396e45..f8a9e4f00 100644 --- a/pip/index.py +++ b/pip/index.py @@ -720,7 +720,7 @@ class PageCache(object): self._archives[url] = value def add_page_failure(self, url, level): - self._failures[url] = self._failures.get(url, 0)+level + self._failures[url] = self._failures.get(url, 0) + level def add_page(self, urls, page): for url in urls: diff --git a/pip/locations.py b/pip/locations.py index b270349d0..c986c6342 100644 --- a/pip/locations.py +++ b/pip/locations.py @@ -177,7 +177,7 @@ def distutils_scheme(dist_name, user=False, home=None, root=None): i.root = root or i.root i.finalize_options() for key in SCHEME_KEYS: - scheme[key] = getattr(i, 'install_'+key) + scheme[key] = getattr(i, 'install_' + key) if running_under_virtualenv(): scheme['headers'] = os.path.join( diff --git a/pip/req/req_install.py b/pip/req/req_install.py index 4dc7fc3d6..3183431ed 100644 --- a/pip/req/req_install.py +++ b/pip/req/req_install.py @@ -391,7 +391,7 @@ exec(compile( if ( os.path.exists( os.path.join(root, dir, 'bin', 'python') - ) + ) or os.path.exists( os.path.join( root, dir, 'Scripts', 'Python.exe' @@ -703,9 +703,10 @@ exec(compile( logger.notify('Saved %s' % display_path(archive_path)) def _clean_zip_name(self, name, prefix): - assert name.startswith(prefix+os.path.sep), ( - "name %r doesn't start with prefix %r" % (name, prefix)) - name = name[len(prefix)+1:] + assert name.startswith(prefix + os.path.sep), ( + "name %r doesn't start with prefix %r" % (name, prefix) + ) + name = name[len(prefix) + 1:] name = name.replace(os.path.sep, '/') return name @@ -805,7 +806,7 @@ exec(compile( ) f.close() f = open(os.path.join(egg_info_dir, 'installed-files.txt'), 'w') - f.write('\n'.join(new_lines)+'\n') + f.write('\n'.join(new_lines) + '\n') f.close() finally: if os.path.exists(record_filename): diff --git a/pip/req/req_set.py b/pip/req/req_set.py index 59e611ffb..8079d544d 100644 --- a/pip/req/req_set.py +++ b/pip/req/req_set.py @@ -350,7 +350,7 @@ class RequirementSet(object): self.unpack_url( url, location, download_dir, do_download, - ) + ) except HTTPError as exc: logger.fatal( 'Could not install requirement %s because ' @@ -728,8 +728,9 @@ class RequirementSet(object): return ''.join(parts) def _clean_zip_name(self, name, prefix): - assert name.startswith(prefix+os.path.sep), ( - "name %r doesn't start with prefix %r" % (name, prefix)) - name = name[len(prefix)+1:] + assert name.startswith(prefix + os.path.sep), ( + "name %r doesn't start with prefix %r" % (name, prefix) + ) + name = name[len(prefix) + 1:] name = name.replace(os.path.sep, '/') return name diff --git a/pip/util.py b/pip/util.py index 6cb5b1871..569f56a5f 100644 --- a/pip/util.py +++ b/pip/util.py @@ -188,12 +188,12 @@ def normalize_name(name): def format_size(bytes): - if bytes > 1000*1000: - return '%.1fMB' % (bytes/1000.0/1000) - elif bytes > 10*1000: - return '%ikB' % (bytes/1000) + if bytes > 1000 * 1000: + return '%.1fMB' % (bytes / 1000.0 / 1000) + elif bytes > 10 * 1000: + return '%ikB' % (bytes / 1000) elif bytes > 1000: - return '%.1fkB' % (bytes/1000.0) + return '%.1fkB' % (bytes / 1000.0) else: return '%ibytes' % bytes @@ -274,7 +274,7 @@ def make_path_relative(path, rel_to): while path_parts and rel_to_parts and path_parts[0] == rel_to_parts[0]: path_parts.pop(0) rel_to_parts.pop(0) - full_parts = ['..']*len(rel_to_parts) + path_parts + [path_filename] + full_parts = ['..'] * len(rel_to_parts) + path_parts + [path_filename] if full_parts == ['']: return '.' + os.path.sep return os.path.sep.join(full_parts) @@ -540,7 +540,7 @@ def unzip_file(filename, location, flatten=True): if mode and stat.S_ISREG(mode) and mode & 0o111: # make dest file have execute for user/group/world # (chmod +x) no-op on windows per python docs - os.chmod(fn, (0o777-current_umask() | 0o111)) + os.chmod(fn, (0o777 - current_umask() | 0o111)) finally: zipfp.close() @@ -615,7 +615,7 @@ def untar_file(filename, location): if member.mode & 0o111: # make dest file have execute for user/group/world # no-op on windows per python docs - os.chmod(path, (0o777-current_umask() | 0o111)) + os.chmod(path, (0o777 - current_umask() | 0o111)) finally: tar.close() @@ -632,7 +632,7 @@ def cache_download(target_file, temp_location, content_type): 'Storing download in cache at %s' % display_path(target_file) ) shutil.copyfile(temp_location, target_file) - fp = open(target_file+'.content-type', 'w') + fp = open(target_file + '.content-type', 'w') fp.write(content_type) fp.close() diff --git a/pip/wheel.py b/pip/wheel.py index b2ac7e59d..fdcf31549 100644 --- a/pip/wheel.py +++ b/pip/wheel.py @@ -393,7 +393,7 @@ def uninstallation_paths(dist): if path.endswith('.py'): dn, fn = os.path.split(path) base = fn[:-3] - path = os.path.join(dn, base+'.pyc') + path = os.path.join(dn, base + '.pyc') yield path diff --git a/tests/functional/test_bundle.py b/tests/functional/test_bundle.py index f8d550169..f6dfe630f 100644 --- a/tests/functional/test_bundle.py +++ b/tests/functional/test_bundle.py @@ -12,7 +12,7 @@ def test_create_bundle(script, tmpdir, data): index (pip itself). """ - fspkg = path_to_url(data.packages/'FSPkg') + fspkg = path_to_url(data.packages / 'FSPkg') script.pip('install', '-e', fspkg) pkg_lines = textwrap.dedent( ''' @@ -61,13 +61,13 @@ def test_cleanup_after_create_bundle(script, tmpdir, data): ), ]) script.pip(*args) - build = script.venv_path/"build" - src = script.venv_path/"src" + build = script.venv_path / "build" + src = script.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 = path_to_url(data.packages/'FSPkg') + fspkg = path_to_url(data.packages / 'FSPkg') pkg_lines = textwrap.dedent( ''' -e %s @@ -86,8 +86,8 @@ def test_cleanup_after_create_bundle(script, tmpdir, data): script.pip( 'bundle', '--no-use-wheel', '-r', 'bundle-req.txt', 'test.pybundle', ) - build_bundle = script.scratch_path/"build-bundle" - src_bundle = script.scratch_path/"src-bundle" + build_bundle = script.scratch_path / "build-bundle" + src_bundle = script.scratch_path / "src-bundle" assert not exists(build_bundle), ( "build-bundle/ dir still exists: %s" % build_bundle ) diff --git a/tests/functional/test_freeze.py b/tests/functional/test_freeze.py index 0d430e642..8a192c37e 100644 --- a/tests/functional/test_freeze.py +++ b/tests/functional/test_freeze.py @@ -32,7 +32,7 @@ def _check_output(result, expected): return '\n========== %s ==========\n' % msg assert checker.check_output(expected, actual, ELLIPSIS), ( banner('EXPECTED') + expected + banner('ACTUAL') + actual + - banner(6*'=') + banner(6 * '=') ) @@ -51,7 +51,7 @@ def test_freeze_basic(script): simple2<=3.0 """)) result = script.pip_install_local( - '-r', script.scratch_path/'initools-req.txt', + '-r', script.scratch_path / 'initools-req.txt', ) result = script.pip('freeze', expect_stderr=True) expected = textwrap.dedent("""\ @@ -178,7 +178,7 @@ def test_freeze_mercurial_clone(script, tmpdir): ) result = script.run( 'python', 'setup.py', 'develop', - cwd=script.scratch_path/'pip-test-package', + cwd=script.scratch_path / 'pip-test-package', expect_stderr=True, ) result = script.pip('freeze', expect_stderr=True) @@ -248,7 +248,7 @@ def test_freeze_bazaar_clone(script, tmpdir): ) result = script.run( 'python', 'setup.py', 'develop', - cwd=script.scratch_path/'django-wikiapp', + cwd=script.scratch_path / 'django-wikiapp', ) result = script.pip('freeze', expect_stderr=True) expected = textwrap.dedent("""\ diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index a0836b62e..d2fcdd65a 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -100,15 +100,15 @@ def test_download_editable_to_custom_path(script, tmpdir): '--download', 'customdl', ) - customsrc = Path('scratch')/'customsrc'/'initools' + customsrc = Path('scratch') / 'customsrc' / 'initools' assert customsrc in result.files_created, ( sorted(result.files_created.keys()) ) - assert customsrc/'setup.py' in result.files_created, ( + assert customsrc / 'setup.py' in result.files_created, ( sorted(result.files_created.keys()) ) - customdl = Path('scratch')/'customdl'/'initools' + customdl = Path('scratch') / 'customdl' / 'initools' customdl_files_created = [ filename for filename in result.files_created if filename.startswith(customdl) @@ -156,10 +156,10 @@ def test_no_install_followed_by_no_download(script): --no-download). """ egg_info_folder = ( - script.site_packages/'INITools-0.2-py%s.egg-info' % pyversion + script.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion ) - initools_folder = script.site_packages/'initools' - build_dir = script.venv/'build'/'INITools' + initools_folder = script.site_packages / 'initools' + build_dir = script.venv / 'build' / 'INITools' result1 = script.pip( 'install', 'INITools==0.2', '--no-install', expect_error=True, @@ -169,7 +169,7 @@ def test_no_install_followed_by_no_download(script): sorted(result1.files_created) ) assert build_dir in result1.files_created, result1.files_created - assert build_dir/'INITools.egg-info' in result1.files_created + assert build_dir / 'INITools.egg-info' in result1.files_created result2 = script.pip( 'install', 'INITools==0.2', '--no-download', expect_error=True, @@ -179,7 +179,7 @@ def test_no_install_followed_by_no_download(script): sorted(result2.files_created) ) assert build_dir not in result2.files_created - assert build_dir/'INITools.egg-info' not in result2.files_created + assert build_dir / 'INITools.egg-info' not in result2.files_created def test_bad_install_with_no_download(script): @@ -304,9 +304,9 @@ def test_install_from_local_directory(script, data): """ to_install = data.packages.join("FSPkg") result = script.pip('install', to_install, expect_error=False) - fspkg_folder = script.site_packages/'fspkg' + fspkg_folder = script.site_packages / 'fspkg' egg_info_folder = ( - script.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion + script.site_packages / 'FSPkg-0.1dev-py%s.egg-info' % pyversion ) assert fspkg_folder in result.files_created, str(result.stdout) assert egg_info_folder in result.files_created, str(result) @@ -319,9 +319,9 @@ def test_install_from_local_directory_with_symlinks_to_directories( """ to_install = data.packages.join("symlinks") result = script.pip('install', to_install, expect_error=False) - pkg_folder = script.site_packages/'symlinks' + pkg_folder = script.site_packages / 'symlinks' egg_info_folder = ( - script.site_packages/'symlinks-0.1dev-py%s.egg-info' % pyversion + script.site_packages / 'symlinks-0.1dev-py%s.egg-info' % pyversion ) assert pkg_folder in result.files_created, str(result.stdout) assert egg_info_folder in result.files_created, str(result) @@ -353,8 +353,8 @@ def test_install_as_egg(script, data): """ to_install = data.packages.join("FSPkg") result = script.pip('install', to_install, '--egg', expect_error=False) - fspkg_folder = script.site_packages/'fspkg' - egg_folder = script.site_packages/'FSPkg-0.1dev-py%s.egg' % pyversion + fspkg_folder = script.site_packages / 'fspkg' + egg_folder = script.site_packages / 'FSPkg-0.1dev-py%s.egg' % pyversion assert fspkg_folder not in result.files_created, str(result.stdout) assert egg_folder in result.files_created, str(result) assert join(egg_folder, 'fspkg') in result.files_created, str(result) @@ -370,9 +370,9 @@ def test_install_curdir(script, data): if os.path.isdir(egg_info): rmtree(egg_info) result = script.pip('install', curdir, cwd=run_from, expect_error=False) - fspkg_folder = script.site_packages/'fspkg' + fspkg_folder = script.site_packages / 'fspkg' egg_info_folder = ( - script.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion + script.site_packages / 'FSPkg-0.1dev-py%s.egg-info' % pyversion ) assert fspkg_folder in result.files_created, str(result.stdout) assert egg_info_folder in result.files_created, str(result) @@ -384,9 +384,9 @@ def test_install_pardir(script, data): """ run_from = data.packages.join("FSPkg", "fspkg") result = script.pip('install', pardir, cwd=run_from, expect_error=False) - fspkg_folder = script.site_packages/'fspkg' + fspkg_folder = script.site_packages / 'fspkg' egg_info_folder = ( - script.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion + script.site_packages / 'FSPkg-0.1dev-py%s.egg-info' % pyversion ) assert fspkg_folder in result.files_created, str(result.stdout) assert egg_info_folder in result.files_created, str(result) @@ -432,7 +432,7 @@ def test_install_using_install_option_and_editable(script, tmpdir): '--install-option=--script-dir=%s' % folder ) virtualenv_bin = ( - script.venv/'src'/'virtualenv'/folder/'virtualenv'+script.exe + script.venv / 'src' / 'virtualenv' / folder / 'virtualenv' + script.exe ) assert virtualenv_bin in result.files_created @@ -470,7 +470,7 @@ def test_install_folder_using_dot_slash(script): Test installing a folder using pip install ./foldername """ script.scratch_path.join("mock").mkdir() - pkg_path = script.scratch_path/'mock' + pkg_path = script.scratch_path / 'mock' pkg_path.join("setup.py").write(mock100_setup_py) result = script.pip('install', './mock') egg_folder = script.site_packages / 'mock-100.1-py%s.egg-info' % pyversion @@ -482,7 +482,7 @@ def test_install_folder_using_slash_in_the_end(script): Test installing a folder using pip install foldername/ or foldername\ """ script.scratch_path.join("mock").mkdir() - pkg_path = script.scratch_path/'mock' + pkg_path = script.scratch_path / 'mock' pkg_path.join("setup.py").write(mock100_setup_py) result = script.pip('install', 'mock' + os.path.sep) egg_folder = script.site_packages / 'mock-100.1-py%s.egg-info' % pyversion @@ -495,9 +495,9 @@ def test_install_folder_using_relative_path(script): """ script.scratch_path.join("initools").mkdir() script.scratch_path.join("initools", "mock").mkdir() - pkg_path = script.scratch_path/'initools'/'mock' + pkg_path = script.scratch_path / 'initools' / 'mock' pkg_path.join("setup.py").write(mock100_setup_py) - result = script.pip('install', Path('initools')/'mock') + result = script.pip('install', Path('initools') / 'mock') egg_folder = script.site_packages / 'mock-100.1-py%s.egg-info' % pyversion assert egg_folder in result.files_created, str(result) @@ -507,9 +507,10 @@ def test_install_package_which_contains_dev_in_name(script): Test installing package from pypi which contains 'dev' in name """ result = script.pip('install', 'django-devserver==0.0.4') - devserver_folder = script.site_packages/'devserver' + devserver_folder = script.site_packages / 'devserver' egg_info_folder = ( - script.site_packages/'django_devserver-0.0.4-py%s.egg-info' % pyversion + script.site_packages / 'django_devserver-0.0.4-py%s.egg-info' % + pyversion ) assert devserver_folder in result.files_created, str(result.stdout) assert egg_info_folder in result.files_created, str(result) @@ -519,9 +520,9 @@ def test_install_package_with_target(script): """ Test installing a package using pip install --target """ - target_dir = script.scratch_path/'target' + target_dir = script.scratch_path / 'target' result = script.pip('install', '-t', target_dir, "initools==0.1") - assert Path('scratch')/'target'/'initools' in result.files_created, ( + assert Path('scratch') / 'target' / 'initools' in result.files_created, ( str(result) ) @@ -530,7 +531,7 @@ def test_install_package_with_root(script, data): """ Test installing a package using pip install --root """ - root_dir = script.scratch_path/'root' + root_dir = script.scratch_path / 'root' result = script.pip( 'install', '--root', root_dir, '-f', data.find_links, '--no-index', 'simple==1.0', @@ -609,11 +610,11 @@ def test_compiles_pyc(script): # There are many locations for the __init__.pyc file so attempt to find # any of them exists = [ - os.path.exists(script.site_packages_path/"initools/__init__.pyc"), + os.path.exists(script.site_packages_path / "initools/__init__.pyc"), ] exists += glob.glob( - script.site_packages_path/"initools/__pycache__/__init__*.pyc" + script.site_packages_path / "initools/__pycache__/__init__*.pyc" ) assert any(exists) @@ -629,11 +630,11 @@ def test_no_compiles_pyc(script, data): # There are many locations for the __init__.pyc file so attempt to find # any of them exists = [ - os.path.exists(script.site_packages_path/"initools/__init__.pyc"), + os.path.exists(script.site_packages_path / "initools/__init__.pyc"), ] exists += glob.glob( - script.site_packages_path/"initools/__pycache__/__init__*.pyc" + script.site_packages_path / "initools/__pycache__/__init__*.pyc" ) assert not any(exists) diff --git a/tests/functional/test_install_cleanup.py b/tests/functional/test_install_cleanup.py index 8f7e62b16..f677a3cc5 100644 --- a/tests/functional/test_install_cleanup.py +++ b/tests/functional/test_install_cleanup.py @@ -15,8 +15,8 @@ def test_cleanup_after_install(script, data): script.pip( 'install', '--no-index', '--find-links=%s' % data.find_links, 'simple' ) - build = script.venv_path/"build" - src = script.venv_path/"src" + build = script.venv_path / "build" + src = script.venv_path / "src" assert not exists(build), "build/ dir still exists: %s" % build assert not exists(src), "unexpected src/ dir exists: %s" % src script.assert_no_temp() @@ -30,7 +30,7 @@ def test_no_clean_option_blocks_cleaning_after_install(script, data): 'install', '--no-clean', '--no-index', '--find-links=%s' % data.find_links, 'simple' ) - build = script.venv_path/'build'/'simple' + build = script.venv_path / 'build' / 'simple' assert exists(build), "build/simple should still exist %s" % str(result) @@ -49,8 +49,8 @@ def test_cleanup_after_install_editable_from_hg(script, tmpdir): ), expect_error=True, ) - build = script.venv_path/'build' - src = script.venv_path/'src' + build = script.venv_path / 'build' + src = script.venv_path / 'src' assert not exists(build), "build/ dir still exists: %s" % build assert exists(src), "expected src/ dir doesn't exist: %s" % src script.assert_no_temp() @@ -62,8 +62,8 @@ def test_cleanup_after_install_from_local_directory(script, data): """ to_install = data.packages.join("FSPkg") script.pip('install', to_install, expect_error=False) - build = script.venv_path/'build' - src = script.venv_path/'src' + build = script.venv_path / 'build' + src = script.venv_path / 'src' assert not exists(build), "unexpected build/ dir exists: %s" % build assert not exists(src), "unexpected src/ dir exist: %s" % src script.assert_no_temp() @@ -74,15 +74,15 @@ def test_no_install_and_download_should_not_leave_build_dir(script): It should remove build/ dir if it was pip that created """ script.scratch_path.join("downloaded_packages").mkdir() - assert not os.path.exists(script.venv_path/'/build') + assert not os.path.exists(script.venv_path / '/build') result = script.pip( 'install', '--no-install', 'INITools==0.2', '-d', 'downloaded_packages' ) assert ( - Path('scratch')/'downloaded_packages/build' + Path('scratch') / 'downloaded_packages/build' not in result.files_created ), 'pip should not leave build/ dir' - assert not os.path.exists(script.venv_path/'/build'), ( + assert not os.path.exists(script.venv_path / '/build'), ( "build/ dir should be deleted" ) @@ -102,7 +102,7 @@ def test_cleanup_req_satisifed_no_name(script, data): script.pip('install', dist) script.pip('install', dist) - build = script.venv_path/'build' + build = script.venv_path / 'build' assert not exists(build), "unexpected build/ dir exists: %s" % build script.assert_no_temp() @@ -114,15 +114,15 @@ def test_download_should_not_delete_existing_build_dir(script): script.venv_path.join("build").mkdir() script.venv_path.join("build", "somefile.txt").write("I am not empty!") script.pip('install', '--no-install', 'INITools==0.2', '-d', '.') - with open(script.venv_path/'build'/'somefile.txt') as fp: + with open(script.venv_path / 'build' / 'somefile.txt') as fp: content = fp.read() - assert os.path.exists(script.venv_path/'build'), ( + assert os.path.exists(script.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(script.venv_path/'build') + assert ['somefile.txt'] == os.listdir(script.venv_path / 'build') def test_cleanup_after_install_exception(script, data): @@ -134,7 +134,7 @@ def test_cleanup_after_install_exception(script, data): 'install', '-f', data.find_links, '--no-index', 'broken==0.2broken', expect_error=True, ) - build = script.venv_path/'build' + build = script.venv_path / 'build' assert not exists(build), "build/ dir still exists: %s" % result.stdout script.assert_no_temp() @@ -148,7 +148,7 @@ def test_cleanup_after_egg_info_exception(script, data): 'install', '-f', data.find_links, '--no-index', 'brokenegginfo==0.1', expect_error=True, ) - build = script.venv_path/'build' + build = script.venv_path / 'build' assert not exists(build), "build/ dir still exists: %s" % result.stdout script.assert_no_temp() @@ -157,9 +157,9 @@ def test_cleanup_prevented_upon_build_dir_exception(script, data): """ Test no cleanup occurs after a PreviousBuildDirError """ - build = script.venv_path/'build'/'simple' + build = script.venv_path / 'build' / 'simple' os.makedirs(build) - write_delete_marker_file(script.venv_path/'build') + write_delete_marker_file(script.venv_path / 'build') build.join("setup.py").write("#") result = script.pip( 'install', '-f', data.find_links, '--no-index', 'simple', diff --git a/tests/functional/test_install_compat.py b/tests/functional/test_install_compat.py index a906aaa9e..3f56bd8f9 100644 --- a/tests/functional/test_install_compat.py +++ b/tests/functional/test_install_compat.py @@ -41,7 +41,7 @@ def test_debian_egg_name_workaround(script): # Try the uninstall and verify that everything is removed. result2 = script.pip("uninstall", "INITools", "-y") - assert_all_changes(result, result2, [script.venv/'build', 'cache']) + assert_all_changes(result, result2, [script.venv / 'build', 'cache']) def test_setup_py_with_dos_line_endings(script, data): diff --git a/tests/functional/test_install_config.py b/tests/functional/test_install_config.py index 399b78bcb..028016d0e 100644 --- a/tests/functional/test_install_config.py +++ b/tests/functional/test_install_config.py @@ -60,7 +60,7 @@ def _test_env_vars_override_config_file(script, virtualenv, config_file): # 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. - (script.scratch_path/config_file).write(textwrap.dedent("""\ + (script.scratch_path / config_file).write(textwrap.dedent("""\ [global] no-index = 1 """)) @@ -135,7 +135,7 @@ def test_config_file_override_stack(script, virtualenv): def _test_config_file_override_stack(script, virtualenv, config_file): # set this to make pip load it script.environ['PIP_CONFIG_FILE'] = config_file - (script.scratch_path/config_file).write(textwrap.dedent("""\ + (script.scratch_path / config_file).write(textwrap.dedent("""\ [global] index-url = http://download.zope.org/ppix """)) @@ -144,7 +144,7 @@ def _test_config_file_override_stack(script, virtualenv, config_file): "Getting page http://download.zope.org/ppix/INITools" in result.stdout ) virtualenv.clear() - (script.scratch_path/config_file).write(textwrap.dedent("""\ + (script.scratch_path / config_file).write(textwrap.dedent("""\ [global] index-url = http://download.zope.org/ppix [install] diff --git a/tests/functional/test_install_index.py b/tests/functional/test_install_index.py index d30312c21..17ff43aab 100644 --- a/tests/functional/test_install_index.py +++ b/tests/functional/test_install_index.py @@ -65,9 +65,9 @@ def test_file_index_url_quoting(script, data): 'install', '-vvv', '--index-url', index_url, 'simple', expect_error=False, ) - assert (script.site_packages/'simple') in result.files_created, ( + assert (script.site_packages / 'simple') in result.files_created, ( str(result.stdout) ) assert ( - script.site_packages/'simple-1.0-py%s.egg-info' % pyversion + script.site_packages / 'simple-1.0-py%s.egg-info' % pyversion ) in result.files_created, str(result) diff --git a/tests/functional/test_install_reqs.py b/tests/functional/test_install_reqs.py index 00eeb40ee..ec851744f 100644 --- a/tests/functional/test_install_reqs.py +++ b/tests/functional/test_install_reqs.py @@ -23,13 +23,13 @@ def test_requirements_file(script): 'install', '-r', script.scratch_path / 'initools-req.txt' ) assert ( - script.site_packages/'INITools-0.2-py%s.egg-info' % + script.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion in result.files_created ) - assert script.site_packages/'initools' in result.files_created - assert result.files_created[script.site_packages/other_lib_name].dir + assert script.site_packages / 'initools' in result.files_created + assert result.files_created[script.site_packages / other_lib_name].dir fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion) - assert result.files_created[script.site_packages/fn].dir + assert result.files_created[script.site_packages / fn].dir def test_schema_check_in_requirements_file(script): @@ -66,9 +66,9 @@ def test_relative_requirements_file(script, data): 'install', '-vvv', '-r', script.scratch_path / 'file-egg-req.txt' ) assert ( - script.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion + script.site_packages / 'FSPkg-0.1dev-py%s.egg-info' % pyversion ) in result.files_created, str(result) - assert (script.site_packages/'fspkg') in result.files_created, ( + assert (script.site_packages / 'fspkg') in result.files_created, ( str(result.stdout) ) @@ -98,10 +98,10 @@ def test_multiple_requirements_files(script, tmpdir): result = script.pip( 'install', '-r', script.scratch_path / 'initools-req.txt' ) - assert result.files_created[script.site_packages/other_lib_name].dir + assert result.files_created[script.site_packages / other_lib_name].dir fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion) - assert result.files_created[script.site_packages/fn].dir - assert script.venv/'src'/'initools' in result.files_created + assert result.files_created[script.site_packages / fn].dir + assert script.venv / 'src' / 'initools' in result.files_created def test_respect_order_in_requirements_file(script, data): @@ -136,13 +136,13 @@ def test_install_local_editable_with_extras(script, data): 'install', '-e', to_install + '[bar]', '--process-dependency-links', expect_error=False, ) - assert script.site_packages/'easy-install.pth' in res.files_updated, ( + assert script.site_packages / 'easy-install.pth' in res.files_updated, ( str(res) ) - assert script.site_packages/'LocalExtras.egg-link' in res.files_created, ( - str(res) - ) - assert script.site_packages/'simple' in res.files_created, str(res) + assert ( + script.site_packages / 'LocalExtras.egg-link' in res.files_created + ), str(res) + assert script.site_packages / 'simple' in res.files_created, str(res) def test_install_local_editable_with_subdirectory(script): diff --git a/tests/functional/test_install_upgrade.py b/tests/functional/test_install_upgrade.py index ef3978026..15f14e4d3 100644 --- a/tests/functional/test_install_upgrade.py +++ b/tests/functional/test_install_upgrade.py @@ -34,11 +34,11 @@ def test_upgrade_to_specific_version(script): 'pip install with specific version did not upgrade' ) assert ( - script.site_packages/'INITools-0.1-py%s.egg-info' % + script.site_packages / 'INITools-0.1-py%s.egg-info' % pyversion in result.files_deleted ) assert ( - script.site_packages/'INITools-0.2-py%s.egg-info' % + script.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion in result.files_created ) @@ -52,7 +52,7 @@ def test_upgrade_if_requested(script): result = script.pip('install', '--upgrade', 'INITools', expect_error=True) assert result.files_created, 'pip install --upgrade did not upgrade' assert ( - script.site_packages/'INITools-0.1-py%s.egg-info' % + script.site_packages / 'INITools-0.1-py%s.egg-info' % pyversion not in result.files_created ) @@ -84,7 +84,7 @@ def test_upgrade_force_reinstall_newest(script): ) assert result2.files_updated, 'upgrade to INITools 0.3 failed' result3 = script.pip('uninstall', 'initools', '-y', expect_error=True) - assert_all_changes(result, result3, [script.venv/'build', 'cache']) + assert_all_changes(result, result3, [script.venv / 'build', 'cache']) def test_uninstall_before_upgrade(script): @@ -99,7 +99,7 @@ def test_uninstall_before_upgrade(script): result2 = script.pip('install', 'INITools==0.3', expect_error=True) assert result2.files_created, 'upgrade to INITools 0.3 failed' result3 = script.pip('uninstall', 'initools', '-y', expect_error=True) - assert_all_changes(result, result3, [script.venv/'build', 'cache']) + assert_all_changes(result, result3, [script.venv / 'build', 'cache']) def test_uninstall_before_upgrade_from_url(script): @@ -119,7 +119,7 @@ def test_uninstall_before_upgrade_from_url(script): ) assert result2.files_created, 'upgrade to INITools 0.3 failed' result3 = script.pip('uninstall', 'initools', '-y', expect_error=True) - assert_all_changes(result, result3, [script.venv/'build', 'cache']) + assert_all_changes(result, result3, [script.venv / 'build', 'cache']) def test_upgrade_to_same_version_from_url(script): @@ -140,7 +140,7 @@ def test_upgrade_to_same_version_from_url(script): ) assert not result2.files_updated, 'INITools 0.3 reinstalled same version' result3 = script.pip('uninstall', 'initools', '-y', expect_error=True) - assert_all_changes(result, result3, [script.venv/'build', 'cache']) + assert_all_changes(result, result3, [script.venv / 'build', 'cache']) def test_upgrade_from_reqs_file(script): @@ -170,7 +170,7 @@ def test_upgrade_from_reqs_file(script): assert_all_changes( install_result, uninstall_result, - [script.venv/'build', 'cache', script.scratch/'test-req.txt'], + [script.venv / 'build', 'cache', script.scratch / 'test-req.txt'], ) @@ -197,7 +197,7 @@ def test_uninstall_rollback(script, data): assert_all_changes( result.files_after, result2, - [script.venv/'build', 'pip-log.txt'], + [script.venv / 'build', 'pip-log.txt'], ) @@ -235,11 +235,11 @@ def test_should_not_install_always_from_cache(script): script.pip('uninstall', '-y', 'INITools') result = script.pip('install', 'INITools==0.1', expect_error=True) assert ( - script.site_packages/'INITools-0.2-py%s.egg-info' % + script.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion not in result.files_created ) assert ( - script.site_packages/'INITools-0.1-py%s.egg-info' % + script.site_packages / 'INITools-0.1-py%s.egg-info' % pyversion in result.files_created ) @@ -253,10 +253,10 @@ def test_install_with_ignoreinstalled_requested(script): assert result.files_created, 'pip install -I did not install' # both the old and new metadata should be present. assert os.path.exists( - script.site_packages_path/'INITools-0.1-py%s.egg-info' % pyversion + script.site_packages_path / 'INITools-0.1-py%s.egg-info' % pyversion ) assert os.path.exists( - script.site_packages_path/'INITools-0.3-py%s.egg-info' % pyversion + script.site_packages_path / 'INITools-0.3-py%s.egg-info' % pyversion ) @@ -298,7 +298,7 @@ class TestUpgradeSetuptools(object): def prep_ve(self, script, version, pip_src, distribute=False): self.script = script self.script.pip_install_local('virtualenv==%s' % version) - args = ['virtualenv', self.script.scratch_path/'VE'] + args = ['virtualenv', self.script.scratch_path / 'VE'] if distribute: args.insert(1, '--distribute') if version == "1.9.1" and not distribute: @@ -309,10 +309,10 @@ class TestUpgradeSetuptools(object): bindir = "Scripts" else: bindir = "bin" - self.ve_bin = self.script.scratch_path/'VE'/bindir - self.script.run(self.ve_bin/'pip', 'uninstall', '-y', 'pip') + self.ve_bin = self.script.scratch_path / 'VE' / bindir + self.script.run(self.ve_bin / 'pip', 'uninstall', '-y', 'pip') self.script.run( - self.ve_bin/'python', 'setup.py', 'install', + self.ve_bin / 'python', 'setup.py', 'install', cwd=pip_src, expect_stderr=True, ) @@ -322,13 +322,13 @@ class TestUpgradeSetuptools(object): self, script, data, virtualenv): self.prep_ve(script, '1.9.1', virtualenv.pip_source_dir) result = self.script.run( - self.ve_bin/'pip', 'install', '--no-use-wheel', '--no-index', + self.ve_bin / 'pip', 'install', '--no-use-wheel', '--no-index', '--find-links=%s' % data.find_links, '-U', 'setuptools' ) assert ( "Found existing installation: setuptools 0.6c11" in result.stdout ) - result = self.script.run(self.ve_bin/'pip', 'list') + result = self.script.run(self.ve_bin / 'pip', 'list') "setuptools (0.9.8)" in result.stdout def test_py2_py3_from_distribute_6_to_setuptools_7( @@ -337,37 +337,37 @@ class TestUpgradeSetuptools(object): script, '1.9.1', virtualenv.pip_source_dir, distribute=True ) result = self.script.run( - self.ve_bin/'pip', 'install', '--no-index', + self.ve_bin / 'pip', 'install', '--no-index', '--find-links=%s' % data.find_links, '-U', 'setuptools' ) assert ( "Found existing installation: distribute 0.6.34" in result.stdout ) - result = self.script.run(self.ve_bin/'pip', 'list') + result = self.script.run(self.ve_bin / 'pip', 'list') "setuptools (0.9.8)" in result.stdout "distribute (0.7.3)" in result.stdout def test_from_setuptools_7_to_setuptools_7(self, script, data, virtualenv): self.prep_ve(script, '1.10', virtualenv.pip_source_dir) result = self.script.run( - self.ve_bin/'pip', 'install', '--no-index', + self.ve_bin / 'pip', 'install', '--no-index', '--find-links=%s' % data.find_links, '-U', 'setuptools' ) assert "Found existing installation: setuptools 0.9.7" in result.stdout - result = self.script.run(self.ve_bin/'pip', 'list') + result = self.script.run(self.ve_bin / 'pip', 'list') "setuptools (0.9.8)" in result.stdout def test_from_setuptools_7_to_setuptools_7_using_wheel( self, script, data, virtualenv): self.prep_ve(script, '1.10', virtualenv.pip_source_dir) result = self.script.run( - self.ve_bin/'pip', 'install', '--use-wheel', '--no-index', + self.ve_bin / 'pip', 'install', '--use-wheel', '--no-index', '--find-links=%s' % data.find_links, '-U', 'setuptools' ) assert "Found existing installation: setuptools 0.9.7" in result.stdout # only wheels use dist-info assert 'setuptools-0.9.8.dist-info' in str(result.files_created) - result = self.script.run(self.ve_bin/'pip', 'list') + result = self.script.run(self.ve_bin / 'pip', 'list') "setuptools (0.9.8)" in result.stdout # disabling intermittent travis failure: @@ -379,21 +379,21 @@ class TestUpgradeSetuptools(object): script, '1.9.1', virtualenv.pip_source_dir, distribute=True ) result = self.script.run( - self.ve_bin/'pip', 'install', '--no-index', + self.ve_bin / 'pip', 'install', '--no-index', '--find-links=%s' % data.find_links, '-U', 'setuptools' ) result = self.script.run( - self.ve_bin/'pip', 'install', '--no-index', + self.ve_bin / 'pip', 'install', '--no-index', '--find-links=%s' % data.find_links, 'setuptools==0.9.6' ) - result = self.script.run(self.ve_bin/'pip', 'list') + result = self.script.run(self.ve_bin / 'pip', 'list') "setuptools (0.9.6)" in result.stdout "distribute (0.7.3)" in result.stdout result = self.script.run( - self.ve_bin/'pip', 'install', '--no-index', + self.ve_bin / 'pip', 'install', '--no-index', '--find-links=%s' % data.find_links, '-U', 'setuptools' ) assert "Found existing installation: setuptools 0.9.6" in result.stdout - result = self.script.run(self.ve_bin/'pip', 'list') + result = self.script.run(self.ve_bin / 'pip', 'list') "setuptools (0.9.8)" in result.stdout "distribute (0.7.3)" in result.stdout diff --git a/tests/functional/test_install_user.py b/tests/functional/test_install_user.py index 7f0a17196..4d2f65a4e 100644 --- a/tests/functional/test_install_user.py +++ b/tests/functional/test_install_user.py @@ -85,9 +85,9 @@ class Tests_UserSite: cwd=run_from, expect_error=False, ) - fspkg_folder = script.user_site/'fspkg' + fspkg_folder = script.user_site / 'fspkg' egg_info_folder = ( - script.user_site/'FSPkg-0.1dev-py%s.egg-info' % pyversion + script.user_site / 'FSPkg-0.1dev-py%s.egg-info' % pyversion ) assert fspkg_folder in result.files_created, result.stdout @@ -124,7 +124,8 @@ class Tests_UserSite: ) initools_v3_file = ( # file only in 0.3 - script.base_path/script.user_site/'initools'/'configparser.py' + script.base_path / script.user_site / 'initools' / + 'configparser.py' ) assert egg_info_folder in result2.files_created, str(result2) assert not isfile(initools_v3_file), initools_v3_file @@ -245,7 +246,8 @@ class Tests_UserSite: ) initools_v3_file = ( # file only in 0.3 - script.base_path/script.user_site/'initools'/'configparser.py' + script.base_path / script.user_site / 'initools' / + 'configparser.py' ) assert egg_info_folder in result3.files_created, str(result3) assert not isfile(initools_v3_file), initools_v3_file diff --git a/tests/functional/test_install_vcs.py b/tests/functional/test_install_vcs.py index ae7cf4f47..48d135a85 100644 --- a/tests/functional/test_install_vcs.py +++ b/tests/functional/test_install_vcs.py @@ -113,7 +113,7 @@ def test_git_branch_should_not_be_changed(script, tmpdir): ), expect_error=True, ) - source_dir = script.venv_path/'src'/'pip-test-package' + source_dir = script.venv_path / 'src' / 'pip-test-package' result = script.run('git', 'branch', cwd=source_dir) assert '* master' in result.stdout, result.stdout @@ -144,8 +144,9 @@ def test_git_with_editable_where_egg_contains_dev_string(script, tmpdir): '%s#egg=django-devserver' % local_checkout( 'git+git://github.com/dcramer/django-devserver.git', - tmpdir.join("cache")) + tmpdir.join("cache") ) + ) result.assert_installed('django-devserver', with_files=['.git']) @@ -159,9 +160,10 @@ def test_git_with_non_editable_where_egg_contains_dev_string(script, tmpdir): '%s#egg=django-devserver' % local_checkout( 'git+git://github.com/dcramer/django-devserver.git', - tmpdir.join("cache")), - ) - devserver_folder = script.site_packages/'devserver' + tmpdir.join("cache") + ), + ) + devserver_folder = script.site_packages / 'devserver' assert devserver_folder in result.files_created, str(result) diff --git a/tests/functional/test_install_vcs_git.py b/tests/functional/test_install_vcs_git.py index c92edce78..9750fd875 100644 --- a/tests/functional/test_install_vcs_git.py +++ b/tests/functional/test_install_vcs_git.py @@ -8,7 +8,7 @@ from tests.lib.git_submodule_helpers import ( _change_test_package_submodule, _pull_in_submodule_changes_to_module, _create_test_package_with_submodule, - ) +) def test_get_refs_should_return_tag_name_and_commit_pair(script): @@ -93,10 +93,10 @@ def test_check_submodule_addition(script): module_path, submodule_path = _create_test_package_with_submodule(script) install_result = script.pip( - 'install', '-e', 'git+'+module_path+'#egg=version_pkg' + 'install', '-e', 'git+' + module_path + '#egg=version_pkg' ) assert ( - script.venv/'src/version-pkg/testpkg/static/testfile' + script.venv / 'src/version-pkg/testpkg/static/testfile' in install_result.files_created ) @@ -105,11 +105,12 @@ def test_check_submodule_addition(script): # expect error because git may write to stderr update_result = script.pip( - 'install', '-e', 'git+'+module_path+'#egg=version_pkg', '--upgrade', + 'install', '-e', 'git+' + module_path + '#egg=version_pkg', + '--upgrade', expect_error=True, ) assert ( - script.venv/'src/version-pkg/testpkg/static/testfile2' + script.venv / 'src/version-pkg/testpkg/static/testfile2' in update_result.files_created ) diff --git a/tests/functional/test_install_vcs_svn.py b/tests/functional/test_install_vcs_svn.py index 37391e9c6..ced30b912 100644 --- a/tests/functional/test_install_vcs_svn.py +++ b/tests/functional/test_install_vcs_svn.py @@ -5,22 +5,22 @@ from pip.vcs.subversion import Subversion @patch('pip.vcs.subversion.call_subprocess') def test_obtain_should_recognize_auth_info_url(call_subprocess_mock, script): svn = Subversion(url='svn+http://username:password@svn.example.com/') - svn.obtain(script.scratch_path/'test') + svn.obtain(script.scratch_path / 'test') call_subprocess_mock.assert_called_with([ svn.cmd, 'checkout', '-q', '--username', 'username', '--password', 'password', 'http://username:password@svn.example.com/', - script.scratch_path/'test', + script.scratch_path / 'test', ]) @patch('pip.vcs.subversion.call_subprocess') def test_export_should_recognize_auth_info_url(call_subprocess_mock, script): svn = Subversion(url='svn+http://username:password@svn.example.com/') - svn.export(script.scratch_path/'test') + svn.export(script.scratch_path / 'test') assert call_subprocess_mock.call_args[0] == ( [ svn.cmd, 'export', '--username', 'username', '--password', 'password', 'http://username:password@svn.example.com/', - script.scratch_path/'test', + script.scratch_path / 'test', ], ) diff --git a/tests/functional/test_install_wheel.py b/tests/functional/test_install_wheel.py index 0e832fcfc..5a7d0efed 100644 --- a/tests/functional/test_install_wheel.py +++ b/tests/functional/test_install_wheel.py @@ -39,10 +39,10 @@ def test_install_from_wheel(script, data): """ result = script.pip( 'install', 'has.script==1.0', '--use-wheel', '--no-index', - '--find-links='+data.find_links, + '--find-links=' + data.find_links, expect_error=False, ) - dist_info_folder = script.site_packages/'has.script-1.0.dist-info' + dist_info_folder = script.site_packages / 'has.script-1.0.dist-info' assert dist_info_folder in result.files_created, (dist_info_folder, result.files_created, result.stdout) @@ -56,14 +56,14 @@ def test_install_from_wheel_with_extras(script, data): """ result = script.pip( 'install', 'complex-dist[simple]', '--use-wheel', '--no-index', - '--find-links='+data.find_links, + '--find-links=' + data.find_links, expect_error=False, ) - dist_info_folder = script.site_packages/'complex_dist-0.1.dist-info' + dist_info_folder = script.site_packages / 'complex_dist-0.1.dist-info' assert dist_info_folder in result.files_created, (dist_info_folder, result.files_created, result.stdout) - dist_info_folder = script.site_packages/'simple.dist-0.1.dist-info' + dist_info_folder = script.site_packages / 'simple.dist-0.1.dist-info' assert dist_info_folder in result.files_created, (dist_info_folder, result.files_created, result.stdout) @@ -75,7 +75,7 @@ def test_install_from_wheel_file(script, data): """ package = data.packages.join("simple.dist-0.1-py2.py3-none-any.whl") result = script.pip('install', package, '--no-index', expect_error=False) - dist_info_folder = script.site_packages/'simple.dist-0.1.dist-info' + dist_info_folder = script.site_packages / 'simple.dist-0.1.dist-info' assert dist_info_folder in result.files_created, (dist_info_folder, result.files_created, result.stdout) @@ -90,7 +90,7 @@ def test_install_from_wheel_with_headers(script, data): """ package = data.packages.join("headers.dist-0.1-py2.py3-none-any.whl") result = script.pip('install', package, '--no-index', expect_error=False) - dist_info_folder = script.site_packages/'headers.dist-0.1.dist-info' + dist_info_folder = script.site_packages / 'headers.dist-0.1.dist-info' assert dist_info_folder in result.files_created, (dist_info_folder, result.files_created, result.stdout) @@ -101,12 +101,12 @@ def test_install_wheel_with_target(script, data): Test installing a wheel using pip install --target """ script.pip('install', 'wheel') - target_dir = script.scratch_path/'target' + target_dir = script.scratch_path / 'target' result = script.pip( 'install', 'simple.dist==0.1', '-t', target_dir, '--use-wheel', - '--no-index', '--find-links='+data.find_links, + '--no-index', '--find-links=' + data.find_links, ) - assert Path('scratch')/'target'/'simpledist' in result.files_created, ( + assert Path('scratch') / 'target' / 'simpledist' in result.files_created, ( str(result) ) @@ -115,12 +115,12 @@ def test_install_wheel_with_root(script, data): """ Test installing a wheel using pip install --root """ - root_dir = script.scratch_path/'root' + root_dir = script.scratch_path / 'root' result = script.pip( 'install', 'simple.dist==0.1', '--root', root_dir, '--use-wheel', - '--no-index', '--find-links='+data.find_links, + '--no-index', '--find-links=' + data.find_links, ) - assert Path('scratch')/'root' in result.files_created + assert Path('scratch') / 'root' in result.files_created def test_install_from_wheel_installs_deps(script, data): @@ -145,7 +145,7 @@ def test_install_from_wheel_no_deps(script, data): 'install', '--no-index', '--find-links', data.find_links, '--no-deps', package, ) - pkg_folder = script.site_packages/'source' + pkg_folder = script.site_packages / 'source' assert pkg_folder not in result.files_created @@ -159,7 +159,7 @@ def test_install_user_wheel(script, virtualenv, data): script.pip('install', 'wheel') result = script.pip( 'install', 'has.script==1.0', '--user', '--use-wheel', '--no-index', - '--find-links='+data.find_links, + '--find-links=' + data.find_links, ) egg_info_folder = script.user_site / 'has.script-1.0.dist-info' assert egg_info_folder in result.files_created, str(result) @@ -173,7 +173,7 @@ def test_install_from_wheel_gen_entrypoint(script, data): """ result = script.pip( 'install', 'script.wheel1a==0.1', '--use-wheel', '--no-index', - '--find-links='+data.find_links, + '--find-links=' + data.find_links, expect_error=False, ) if os.name == 'nt': @@ -192,7 +192,7 @@ def test_install_from_wheel_with_legacy(script, data): """ result = script.pip( 'install', 'script.wheel2a==0.1', '--use-wheel', '--no-index', - '--find-links='+data.find_links, + '--find-links=' + data.find_links, expect_error=False, ) @@ -210,7 +210,7 @@ def test_install_from_wheel_no_setuptools_entrypoint(script, data): """ result = script.pip( 'install', 'script.wheel1==0.1', '--use-wheel', '--no-index', - '--find-links='+data.find_links, + '--find-links=' + data.find_links, expect_error=False, ) if os.name == 'nt': @@ -235,7 +235,7 @@ def test_skipping_setuptools_doesnt_skip_legacy(script, data): """ result = script.pip( 'install', 'script.wheel2==0.1', '--use-wheel', '--no-index', - '--find-links='+data.find_links, + '--find-links=' + data.find_links, expect_error=False, ) @@ -254,7 +254,7 @@ def test_install_from_wheel_gui_entrypoint(script, data): """ result = script.pip( 'install', 'script.wheel3==0.1', '--use-wheel', '--no-index', - '--find-links='+data.find_links, + '--find-links=' + data.find_links, expect_error=False, ) if os.name == 'nt': @@ -275,11 +275,11 @@ def test_wheel_compiles_pyc(script, data): # There are many locations for the __init__.pyc file so attempt to find # any of them exists = [ - os.path.exists(script.site_packages_path/"simpledist/__init__.pyc"), + os.path.exists(script.site_packages_path / "simpledist/__init__.pyc"), ] exists += glob.glob( - script.site_packages_path/"simpledist/__pycache__/__init__*.pyc" + script.site_packages_path / "simpledist/__pycache__/__init__*.pyc" ) assert any(exists) @@ -296,11 +296,11 @@ def test_wheel_no_compiles_pyc(script, data): # There are many locations for the __init__.pyc file so attempt to find # any of them exists = [ - os.path.exists(script.site_packages_path/"simpledist/__init__.pyc"), + os.path.exists(script.site_packages_path / "simpledist/__init__.pyc"), ] exists += glob.glob( - script.site_packages_path/"simpledist/__pycache__/__init__*.pyc" + script.site_packages_path / "simpledist/__pycache__/__init__*.pyc" ) assert not any(exists) diff --git a/tests/functional/test_uninstall.py b/tests/functional/test_uninstall.py index b2a03880f..418d5c7d4 100644 --- a/tests/functional/test_uninstall.py +++ b/tests/functional/test_uninstall.py @@ -25,7 +25,7 @@ def test_simple_uninstall(script): # supports it script.run('python', '-c', "import initools") result2 = script.pip('uninstall', 'INITools', '-y') - assert_all_changes(result, result2, [script.venv/'build', 'cache']) + assert_all_changes(result, result2, [script.venv / 'build', 'cache']) def test_uninstall_with_scripts(script): @@ -41,7 +41,7 @@ def test_uninstall_with_scripts(script): assert_all_changes( result, result2, - [script.venv/'build', 'cache', easy_install_pth], + [script.venv / 'build', 'cache', easy_install_pth], ) @@ -58,7 +58,11 @@ def test_uninstall_easy_install_after_import(script): assert_all_changes( result, result2, - [script.venv/'build', 'cache', script.site_packages/'easy-install.pth'] + [ + script.venv / 'build', + 'cache', + script.site_packages / 'easy-install.pth', + ] ) @@ -129,11 +133,11 @@ def test_uninstall_console_scripts(script): args = ['install'] args.append('discover') result = script.pip(*args, **{"expect_error": True}) - assert script.bin/'discover'+script.exe in result.files_created, ( + assert script.bin / 'discover' + script.exe in result.files_created, ( sorted(result.files_created.keys()) ) result2 = script.pip('uninstall', 'discover', '-y', expect_error=True) - assert_all_changes(result, result2, [script.venv/'build', 'cache']) + assert_all_changes(result, result2, [script.venv / 'build', 'cache']) def test_uninstall_easy_installed_console_scripts(script): @@ -143,14 +147,18 @@ def test_uninstall_easy_installed_console_scripts(script): args = ['easy_install'] args.append('discover') result = script.run(*args, **{"expect_stderr": True}) - assert script.bin/'discover'+script.exe in result.files_created, ( + assert script.bin / 'discover' + script.exe in result.files_created, ( sorted(result.files_created.keys()) ) result2 = script.pip('uninstall', 'discover', '-y') assert_all_changes( result, result2, - [script.venv/'build', 'cache', script.site_packages/'easy-install.pth'] + [ + script.venv / 'build', + 'cache', + script.site_packages / 'easy-install.pth', + ] ) @@ -167,14 +175,14 @@ def test_uninstall_editable_from_svn(script, tmpdir): ) result.assert_installed('INITools') result2 = script.pip('uninstall', '-y', 'initools') - assert (script.venv/'src'/'initools' in result2.files_after) + assert (script.venv / 'src' / 'initools' in result2.files_after) assert_all_changes( result, result2, [ - script.venv/'src', - script.venv/'build', - script.site_packages/'easy-install.pth' + script.venv / 'src', + script.venv / 'build', + script.site_packages / 'easy-install.pth' ], ) @@ -217,7 +225,7 @@ def _test_uninstall_editable_with_source_outside_venv( assert_all_changes( result, result3, - [script.venv/'build', script.site_packages/'easy-install.pth'], + [script.venv / 'build', script.site_packages / 'easy-install.pth'], ) @@ -259,10 +267,10 @@ def test_uninstall_from_reqs_file(script, tmpdir): result, result2, [ - script.venv/'build', - script.venv/'src', - script.scratch/'test-req.txt', - script.site_packages/'easy-install.pth', + script.venv / 'build', + script.venv / 'src', + script.scratch / 'test-req.txt', + script.site_packages / 'easy-install.pth', ], ) @@ -273,8 +281,8 @@ def test_uninstall_as_egg(script, data): """ to_install = data.packages.join("FSPkg") result = script.pip('install', to_install, '--egg', expect_error=False) - fspkg_folder = script.site_packages/'fspkg' - egg_folder = script.site_packages/'FSPkg-0.1dev-py%s.egg' % pyversion + fspkg_folder = script.site_packages / 'fspkg' + egg_folder = script.site_packages / 'FSPkg-0.1dev-py%s.egg' % pyversion assert fspkg_folder not in result.files_created, str(result.stdout) assert egg_folder in result.files_created, str(result) @@ -283,9 +291,9 @@ def test_uninstall_as_egg(script, data): result, result2, [ - script.venv/'build', + script.venv / 'build', 'cache', - script.site_packages/'easy-install.pth', + script.site_packages / 'easy-install.pth', ], ) diff --git a/tests/functional/test_uninstall_user.py b/tests/functional/test_uninstall_user.py index 7e55761bd..1ce774127 100644 --- a/tests/functional/test_uninstall_user.py +++ b/tests/functional/test_uninstall_user.py @@ -20,7 +20,7 @@ class Tests_UninstallUserSite: virtualenv.system_site_packages = True result1 = script.pip('install', '--user', 'INITools==0.3') result2 = script.pip('uninstall', '-y', 'INITools') - assert_all_changes(result1, result2, [script.venv/'build', 'cache']) + assert_all_changes(result1, result2, [script.venv / 'build', 'cache']) def test_uninstall_from_usersite_with_dist_in_global_site( self, script, virtualenv): @@ -53,7 +53,7 @@ class Tests_UninstallUserSite: assert script.bin_path not in result3.stdout # uninstall worked - assert_all_changes(result2, result3, [script.venv/'build', 'cache']) + assert_all_changes(result2, result3, [script.venv / 'build', 'cache']) # site still has 0.2 (can't look in result1; have to check) egg_info_folder = ( @@ -74,7 +74,7 @@ class Tests_UninstallUserSite: result1 = script.pip( 'install', '--user', '-e', to_install, expect_error=False, ) - egg_link = script.user_site/'FSPkg.egg-link' + egg_link = script.user_site / 'FSPkg.egg-link' assert egg_link in result1.files_created, str(result1.stdout) #uninstall @@ -84,5 +84,9 @@ class Tests_UninstallUserSite: assert_all_changes( result1, result2, - [script.venv/'build', 'cache', script.user_site/'easy-install.pth'] + [ + script.venv / 'build', + 'cache', + script.user_site / 'easy-install.pth', + ] ) diff --git a/tests/functional/test_wheel.py b/tests/functional/test_wheel.py index 98e61db34..c4187eb13 100644 --- a/tests/functional/test_wheel.py +++ b/tests/functional/test_wheel.py @@ -31,7 +31,7 @@ def test_pip_wheel_success(script, data): 'wheel', '--no-index', '-f', data.find_links, 'simple==3.0', ) wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot - wheel_file_path = script.scratch/'wheelhouse'/wheel_file_name + wheel_file_path = script.scratch / 'wheelhouse' / wheel_file_name assert wheel_file_path in result.files_created, result.stdout assert "Successfully built simple" in result.stdout, result.stdout @@ -45,7 +45,7 @@ def test_pip_wheel_downloads_wheels(script, data): 'wheel', '--no-index', '-f', data.find_links, 'simple.dist', ) wheel_file_name = 'simple.dist-0.1-py2.py3-none-any.whl' - wheel_file_path = script.scratch/'wheelhouse'/wheel_file_name + wheel_file_path = script.scratch / 'wheelhouse' / wheel_file_name assert wheel_file_path in result.files_created, result.stdout assert "Saved" in result.stdout, result.stdout @@ -59,7 +59,7 @@ def test_pip_wheel_fail(script, data): 'wheel', '--no-index', '-f', data.find_links, 'wheelbroken==0.1', ) wheel_file_name = 'wheelbroken-0.1-py%s-none-any.whl' % pyversion_nodot - wheel_file_path = script.scratch/'wheelhouse'/wheel_file_name + wheel_file_path = script.scratch / 'wheelhouse' / wheel_file_name assert wheel_file_path not in result.files_created, ( wheel_file_path, result.files_created, @@ -86,7 +86,7 @@ def test_pip_wheel_ignore_wheels_editables(script, data): script.scratch_path / 'reqs.txt', ) wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot - wheel_file_path = script.scratch/'wheelhouse'/wheel_file_name + wheel_file_path = script.scratch / 'wheelhouse' / wheel_file_name assert wheel_file_path in result.files_created, ( wheel_file_path, result.files_created, @@ -109,7 +109,7 @@ def test_no_clean_option_blocks_cleaning_after_wheel(script, data): 'wheel', '--no-clean', '--no-index', '--find-links=%s' % data.find_links, 'simple', ) - build = script.venv_path/'build'/'simple' + build = script.venv_path / 'build' / 'simple' assert exists(build), "build/simple should still exist %s" % str(result) @@ -125,7 +125,7 @@ def test_pip_wheel_source_deps(script, data): 'requires_source', ) wheel_file_name = 'source-1.0-py%s-none-any.whl' % pyversion_nodot - wheel_file_path = script.scratch/'wheelhouse'/wheel_file_name + wheel_file_path = script.scratch / 'wheelhouse' / wheel_file_name assert wheel_file_path in result.files_created, result.stdout assert "Successfully built source" in result.stdout, result.stdout diff --git a/tests/lib/__init__.py b/tests/lib/__init__.py index 018c2ece6..b8181bbba 100644 --- a/tests/lib/__init__.py +++ b/tests/lib/__init__.py @@ -134,10 +134,10 @@ class TestPipResult(object): e = self.test_env if editable: - pkg_dir = e.venv/'src'/pkg_name.lower() + pkg_dir = e.venv / 'src' / pkg_name.lower() else: without_egg_link = True - pkg_dir = e.site_packages/pkg_name + pkg_dir = e.site_packages / pkg_name if use_user_site: egg_link_path = e.user_site / pkg_name + '.egg-link' @@ -173,9 +173,9 @@ class TestPipResult(object): egg_link_file.bytes)))) if use_user_site: - pth_file = e.user_site/'easy-install.pth' + pth_file = e.user_site / 'easy-install.pth' else: - pth_file = e.site_packages/'easy-install.pth' + pth_file = e.site_packages / 'easy-install.pth' if (pth_file in self.files_updated) == without_egg_link: raise TestFailure('%r unexpectedly %supdated by install' % ( @@ -192,14 +192,14 @@ class TestPipResult(object): sorted(self.files_created.keys()))) for f in with_files: - if not (pkg_dir/f).normpath in self.files_created: + if not (pkg_dir / f).normpath in self.files_created: raise TestFailure( 'Package directory %r missing expected content %r' % (pkg_dir, f) ) for f in without_files: - if (pkg_dir/f).normpath in self.files_created: + if (pkg_dir / f).normpath in self.files_created: raise TestFailure( 'Package directory %r has unexpected content %f' % (pkg_dir, f) @@ -397,7 +397,7 @@ def assert_all_changes(start_state, end_state, expected_changes): def _create_test_package_with_subdirectory(script, subdirectory): script.scratch_path.join("version_pkg").mkdir() - version_pkg_path = script.scratch_path/'version_pkg' + version_pkg_path = script.scratch_path / 'version_pkg' version_pkg_path.join("version_pkg.py").write(textwrap.dedent(""" def main(): print('0.1') @@ -442,7 +442,7 @@ setup(name='version_subpkg', def _create_test_package(script): script.scratch_path.join("version_pkg").mkdir() - version_pkg_path = script.scratch_path/'version_pkg' + version_pkg_path = script.scratch_path / 'version_pkg' version_pkg_path.join("version_pkg.py").write(textwrap.dedent(""" def main(): print('0.1') diff --git a/tests/lib/git_submodule_helpers.py b/tests/lib/git_submodule_helpers.py index 4513a0b70..ae3174f1d 100644 --- a/tests/lib/git_submodule_helpers.py +++ b/tests/lib/git_submodule_helpers.py @@ -5,7 +5,7 @@ import textwrap def _create_test_package_submodule(env): env.scratch_path.join("version_pkg_submodule").mkdir() - submodule_path = env.scratch_path/'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) @@ -31,7 +31,7 @@ def _pull_in_submodule_changes_to_module(env, module_path): '-q', 'origin', 'master', - cwd=module_path/'testpkg/static/', + cwd=module_path / 'testpkg/static/', ) env.run('git', 'commit', '-q', '--author', 'Pip ', @@ -40,9 +40,9 @@ def _pull_in_submodule_changes_to_module(env, module_path): def _create_test_package_with_submodule(env): env.scratch_path.join("version_pkg").mkdir() - version_pkg_path = env.scratch_path/'version_pkg' + version_pkg_path = env.scratch_path / 'version_pkg' version_pkg_path.join("testpkg").mkdir() - pkg_path = version_pkg_path/'testpkg' + pkg_path = version_pkg_path / 'testpkg' pkg_path.join("__init__.py").write("# hello there") pkg_path.join("version_pkg.py").write(textwrap.dedent('''\ diff --git a/tests/lib/local_repos.py b/tests/lib/local_repos.py index c1b45e06c..a64d456b3 100644 --- a/tests/lib/local_repos.py +++ b/tests/lib/local_repos.py @@ -55,7 +55,9 @@ def _get_vcs_and_checkout_url(remote_repository, directory): if vcs == 'svn': branch = os.path.basename(remote_repository) # remove the slash - repository_name = os.path.basename(remote_repository[:-len(branch)-1]) + repository_name = os.path.basename( + remote_repository[:-len(branch) - 1] + ) else: repository_name = os.path.basename(remote_repository) diff --git a/tests/unit/test_download.py b/tests/unit/test_download.py index e79eaecb2..b99e9e7ff 100644 --- a/tests/unit/test_download.py +++ b/tests/unit/test_download.py @@ -262,7 +262,7 @@ class Test_unpack_file_url(object): self.dist_url.url = "%s#md5=%s" % ( self.dist_url.url, dist_path_md5 - ) + ) unpack_file_url(self.dist_url, self.build_dir, download_dir=self.download_dir) diff --git a/tests/unit/test_finder.py b/tests/unit/test_finder.py index dcd4dc4f0..04623f9f1 100644 --- a/tests/unit/test_finder.py +++ b/tests/unit/test_finder.py @@ -76,8 +76,8 @@ def test_finder_detects_latest_already_satisfied_pypi_links(): satisfied_by = Mock( location="/path", parsed_version=parse_version(latest_version), - version=latest_version - ) + version=latest_version, + ) req.satisfied_by = satisfied_by finder = PackageFinder([], ["http://pypi.python.org/simple"]) @@ -156,8 +156,8 @@ class TestWheel: satisfied_by = Mock( location="/path", parsed_version=parse_version(latest_version), - version=latest_version - ) + version=latest_version, + ) req.satisfied_by = satisfied_by finder = PackageFinder([data.find_links], [], use_wheel=True) diff --git a/tests/unit/test_options.py b/tests/unit/test_options.py index 434c496e6..d7a62e1d9 100644 --- a/tests/unit/test_options.py +++ b/tests/unit/test_options.py @@ -38,15 +38,15 @@ class TestOptionPrecedence(object): def get_config_section(self, section): config = { 'global': [('timeout', '-3')], - 'fake': [('timeout', '-2')] - } + 'fake': [('timeout', '-2')], + } return config[section] def get_config_section_global(self, section): config = { 'global': [('timeout', '-3')], - 'fake': [] - } + 'fake': [], + } return config[section] def test_env_override_default_int(self): diff --git a/tests/unit/test_req.py b/tests/unit/test_req.py index 0c931e322..7ce95bd22 100644 --- a/tests/unit/test_req.py +++ b/tests/unit/test_req.py @@ -33,8 +33,8 @@ class TestRequirementSet(object): build_dir=os.path.join(self.tempdir, 'build'), src_dir=os.path.join(self.tempdir, 'src'), download_dir=None, - download_cache=os.path.join(self.tempdir, 'download_cache') - ) + download_cache=os.path.join(self.tempdir, 'download_cache'), + ) def test_no_reuse_existing_build_dir(self, data): """Test prepare_files raise exception with previous build dir""" @@ -51,8 +51,8 @@ class TestRequirementSet(object): "pip can't proceed with [\s\S]*%s[\s\S]*%s" % (req, build_dir.replace('\\', '\\\\')), reqset.prepare_files, - finder - ) + finder, + ) @pytest.mark.parametrize(('file_contents', 'expected'), [ diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py index cf39e8be8..bd5e8f597 100644 --- a/tests/unit/test_util.py +++ b/tests/unit/test_util.py @@ -213,13 +213,13 @@ def test_find_command_folder_in_path(script): looking. """ script.scratch_path.join("path_one").mkdir() - path_one = script.scratch_path/'path_one' + path_one = script.scratch_path / 'path_one' path_one.join("foo").mkdir() script.scratch_path.join("path_two").mkdir() - path_two = script.scratch_path/'path_two' + path_two = script.scratch_path / 'path_two' path_two.join("foo").write("# nothing") found_path = find_command('foo', map(str, [path_one, path_two])) - assert found_path == path_two/'foo' + assert found_path == path_two / 'foo' def test_does_not_find_command_because_there_is_no_path(): @@ -335,8 +335,7 @@ class TestUnpackArchives(object): ('script_group.sh', 0o755, os.path.isfile), ('script_world.sh', 0o755, os.path.isfile), ('dir', 0o755, os.path.isdir), - (os.path.join('dir', 'dirfile'), 0o644, os.path.isfile), - ]: + (os.path.join('dir', 'dirfile'), 0o644, os.path.isfile)]: path = os.path.join(self.tempdir, fname) if path.endswith('symlink.txt') and sys.platform == 'win32': # no symlinks created on windows diff --git a/tox.ini b/tox.ini index 2cf1efa73..59e9d93f1 100644 --- a/tox.ini +++ b/tox.ini @@ -31,3 +31,4 @@ commands = flake8 . [flake8] exclude = .tox,*.egg,build,_vendor,data +select = E,W,F