Turn on everything in flake8

flake8 ignores some errors by default, these ignored by defaults
change sometimes. This will make things stabler by selecting
everything.
This commit is contained in:
Donald Stufft 2014-02-24 16:52:23 -05:00
parent c8d9368e71
commit 95035fc5c4
36 changed files with 271 additions and 247 deletions

View File

@ -109,7 +109,7 @@ def create_main_parser():
pip_pkg_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) pip_pkg_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
parser.version = 'pip %s from %s (python %s)' % ( 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 # add the general options
gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, parser) gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, parser)
@ -247,8 +247,10 @@ class FrozenRequirement(object):
if ver_match or date_match: if ver_match or date_match:
svn_backend = vcs.get_backend('svn') svn_backend = vcs.get_backend('svn')
if svn_backend: if svn_backend:
svn_location = svn_backend( svn_location = svn_backend().get_location(
).get_location(dist, dependency_links) dist,
dependency_links,
)
if not svn_location: if not svn_location:
logger.warn( logger.warn(
'Warning: cannot find svn location for %s' % req) 'Warning: cannot find svn location for %s' % req)

View File

@ -357,8 +357,8 @@ general_group = {
skip_requirements_regex, skip_requirements_regex,
exists_action, exists_action,
cert, cert,
] ]
} }
index_group = { index_group = {
'name': 'Package Index Options', 'name': 'Package Index Options',
@ -375,5 +375,5 @@ index_group = {
allow_unsafe, allow_unsafe,
no_allow_unsafe, no_allow_unsafe,
process_dependency_links, process_dependency_links,
] ]
} }

View File

@ -357,7 +357,7 @@ class InstallCommand(Command):
for item in os.listdir(lib_dir): for item in os.listdir(lib_dir):
shutil.move( shutil.move(
os.path.join(lib_dir, item), 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) shutil.rmtree(temp_target_dir)
return requirement_set return requirement_set

View File

@ -521,7 +521,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None,
already_cached = ( already_cached = (
os.path.exists(cache_file) and os.path.exists(cache_file) and
os.path.exists(cache_content_type_file) os.path.exists(cache_content_type_file)
) )
if not os.path.isdir(download_cache): if not os.path.isdir(download_cache):
create_download_cache_folder(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( logger.warn(
'Previously-downloaded file %s has bad hash, ' 'Previously-downloaded file %s has bad hash, '
're-downloading.' % temp_location 're-downloading.' % temp_location
) )
temp_location = None temp_location = None
os.unlink(already_downloaded) os.unlink(already_downloaded)
already_downloaded = None already_downloaded = None
@ -564,7 +564,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None,
logger.warn( logger.warn(
'Cached file %s has bad hash, ' 'Cached file %s has bad hash, '
're-downloading.' % temp_location 're-downloading.' % temp_location
) )
temp_location = None temp_location = None
os.unlink(cache_file) os.unlink(cache_file)
os.unlink(cache_content_type_file) os.unlink(cache_content_type_file)
@ -654,7 +654,7 @@ def unpack_file_url(link, location, download_dir=None):
logger.warn( logger.warn(
'Previously-downloaded file %s has bad hash, ' 'Previously-downloaded file %s has bad hash, '
're-downloading.' % link_path 're-downloading.' % link_path
) )
os.unlink(download_path) os.unlink(download_path)
else: else:
already_downloaded = True already_downloaded = True

View File

@ -720,7 +720,7 @@ class PageCache(object):
self._archives[url] = value self._archives[url] = value
def add_page_failure(self, url, level): 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): def add_page(self, urls, page):
for url in urls: for url in urls:

View File

@ -177,7 +177,7 @@ def distutils_scheme(dist_name, user=False, home=None, root=None):
i.root = root or i.root i.root = root or i.root
i.finalize_options() i.finalize_options()
for key in SCHEME_KEYS: for key in SCHEME_KEYS:
scheme[key] = getattr(i, 'install_'+key) scheme[key] = getattr(i, 'install_' + key)
if running_under_virtualenv(): if running_under_virtualenv():
scheme['headers'] = os.path.join( scheme['headers'] = os.path.join(

View File

@ -391,7 +391,7 @@ exec(compile(
if ( if (
os.path.exists( os.path.exists(
os.path.join(root, dir, 'bin', 'python') os.path.join(root, dir, 'bin', 'python')
) )
or os.path.exists( or os.path.exists(
os.path.join( os.path.join(
root, dir, 'Scripts', 'Python.exe' root, dir, 'Scripts', 'Python.exe'
@ -703,9 +703,10 @@ exec(compile(
logger.notify('Saved %s' % display_path(archive_path)) logger.notify('Saved %s' % display_path(archive_path))
def _clean_zip_name(self, name, prefix): def _clean_zip_name(self, name, prefix):
assert name.startswith(prefix+os.path.sep), ( assert name.startswith(prefix + os.path.sep), (
"name %r doesn't start with prefix %r" % (name, prefix)) "name %r doesn't start with prefix %r" % (name, prefix)
name = name[len(prefix)+1:] )
name = name[len(prefix) + 1:]
name = name.replace(os.path.sep, '/') name = name.replace(os.path.sep, '/')
return name return name
@ -805,7 +806,7 @@ exec(compile(
) )
f.close() f.close()
f = open(os.path.join(egg_info_dir, 'installed-files.txt'), 'w') 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() f.close()
finally: finally:
if os.path.exists(record_filename): if os.path.exists(record_filename):

View File

@ -350,7 +350,7 @@ class RequirementSet(object):
self.unpack_url( self.unpack_url(
url, location, download_dir, url, location, download_dir,
do_download, do_download,
) )
except HTTPError as exc: except HTTPError as exc:
logger.fatal( logger.fatal(
'Could not install requirement %s because ' 'Could not install requirement %s because '
@ -728,8 +728,9 @@ class RequirementSet(object):
return ''.join(parts) return ''.join(parts)
def _clean_zip_name(self, name, prefix): def _clean_zip_name(self, name, prefix):
assert name.startswith(prefix+os.path.sep), ( assert name.startswith(prefix + os.path.sep), (
"name %r doesn't start with prefix %r" % (name, prefix)) "name %r doesn't start with prefix %r" % (name, prefix)
name = name[len(prefix)+1:] )
name = name[len(prefix) + 1:]
name = name.replace(os.path.sep, '/') name = name.replace(os.path.sep, '/')
return name return name

View File

@ -188,12 +188,12 @@ def normalize_name(name):
def format_size(bytes): def format_size(bytes):
if bytes > 1000*1000: if bytes > 1000 * 1000:
return '%.1fMB' % (bytes/1000.0/1000) return '%.1fMB' % (bytes / 1000.0 / 1000)
elif bytes > 10*1000: elif bytes > 10 * 1000:
return '%ikB' % (bytes/1000) return '%ikB' % (bytes / 1000)
elif bytes > 1000: elif bytes > 1000:
return '%.1fkB' % (bytes/1000.0) return '%.1fkB' % (bytes / 1000.0)
else: else:
return '%ibytes' % bytes 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]: while path_parts and rel_to_parts and path_parts[0] == rel_to_parts[0]:
path_parts.pop(0) path_parts.pop(0)
rel_to_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 == ['']: if full_parts == ['']:
return '.' + os.path.sep return '.' + os.path.sep
return os.path.sep.join(full_parts) 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: if mode and stat.S_ISREG(mode) and mode & 0o111:
# make dest file have execute for user/group/world # make dest file have execute for user/group/world
# (chmod +x) no-op on windows per python docs # (chmod +x) no-op on windows per python docs
os.chmod(fn, (0o777-current_umask() | 0o111)) os.chmod(fn, (0o777 - current_umask() | 0o111))
finally: finally:
zipfp.close() zipfp.close()
@ -615,7 +615,7 @@ def untar_file(filename, location):
if member.mode & 0o111: if member.mode & 0o111:
# make dest file have execute for user/group/world # make dest file have execute for user/group/world
# no-op on windows per python docs # no-op on windows per python docs
os.chmod(path, (0o777-current_umask() | 0o111)) os.chmod(path, (0o777 - current_umask() | 0o111))
finally: finally:
tar.close() 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) 'Storing download in cache at %s' % display_path(target_file)
) )
shutil.copyfile(temp_location, 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.write(content_type)
fp.close() fp.close()

View File

@ -393,7 +393,7 @@ def uninstallation_paths(dist):
if path.endswith('.py'): if path.endswith('.py'):
dn, fn = os.path.split(path) dn, fn = os.path.split(path)
base = fn[:-3] base = fn[:-3]
path = os.path.join(dn, base+'.pyc') path = os.path.join(dn, base + '.pyc')
yield path yield path

View File

@ -12,7 +12,7 @@ def test_create_bundle(script, tmpdir, data):
index (pip itself). index (pip itself).
""" """
fspkg = path_to_url(data.packages/'FSPkg') fspkg = path_to_url(data.packages / 'FSPkg')
script.pip('install', '-e', fspkg) script.pip('install', '-e', fspkg)
pkg_lines = textwrap.dedent( pkg_lines = textwrap.dedent(
''' '''
@ -61,13 +61,13 @@ def test_cleanup_after_create_bundle(script, tmpdir, data):
), ),
]) ])
script.pip(*args) script.pip(*args)
build = script.venv_path/"build" build = script.venv_path / "build"
src = script.venv_path/"src" src = script.venv_path / "src"
assert not exists(build), "build/ dir still exists: %s" % build assert not exists(build), "build/ dir still exists: %s" % build
assert exists(src), "expected src/ dir doesn't exist: %s" % src assert exists(src), "expected src/ dir doesn't exist: %s" % src
# Make the bundle. # Make the bundle.
fspkg = path_to_url(data.packages/'FSPkg') fspkg = path_to_url(data.packages / 'FSPkg')
pkg_lines = textwrap.dedent( pkg_lines = textwrap.dedent(
''' '''
-e %s -e %s
@ -86,8 +86,8 @@ def test_cleanup_after_create_bundle(script, tmpdir, data):
script.pip( script.pip(
'bundle', '--no-use-wheel', '-r', 'bundle-req.txt', 'test.pybundle', 'bundle', '--no-use-wheel', '-r', 'bundle-req.txt', 'test.pybundle',
) )
build_bundle = script.scratch_path/"build-bundle" build_bundle = script.scratch_path / "build-bundle"
src_bundle = script.scratch_path/"src-bundle" src_bundle = script.scratch_path / "src-bundle"
assert not exists(build_bundle), ( assert not exists(build_bundle), (
"build-bundle/ dir still exists: %s" % build_bundle "build-bundle/ dir still exists: %s" % build_bundle
) )

View File

@ -32,7 +32,7 @@ def _check_output(result, expected):
return '\n========== %s ==========\n' % msg return '\n========== %s ==========\n' % msg
assert checker.check_output(expected, actual, ELLIPSIS), ( assert checker.check_output(expected, actual, ELLIPSIS), (
banner('EXPECTED') + expected + banner('ACTUAL') + actual + banner('EXPECTED') + expected + banner('ACTUAL') + actual +
banner(6*'=') banner(6 * '=')
) )
@ -51,7 +51,7 @@ def test_freeze_basic(script):
simple2<=3.0 simple2<=3.0
""")) """))
result = script.pip_install_local( 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) result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\ expected = textwrap.dedent("""\
@ -178,7 +178,7 @@ def test_freeze_mercurial_clone(script, tmpdir):
) )
result = script.run( result = script.run(
'python', 'setup.py', 'develop', 'python', 'setup.py', 'develop',
cwd=script.scratch_path/'pip-test-package', cwd=script.scratch_path / 'pip-test-package',
expect_stderr=True, expect_stderr=True,
) )
result = script.pip('freeze', expect_stderr=True) result = script.pip('freeze', expect_stderr=True)
@ -248,7 +248,7 @@ def test_freeze_bazaar_clone(script, tmpdir):
) )
result = script.run( result = script.run(
'python', 'setup.py', 'develop', 'python', 'setup.py', 'develop',
cwd=script.scratch_path/'django-wikiapp', cwd=script.scratch_path / 'django-wikiapp',
) )
result = script.pip('freeze', expect_stderr=True) result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\ expected = textwrap.dedent("""\

View File

@ -100,15 +100,15 @@ def test_download_editable_to_custom_path(script, tmpdir):
'--download', '--download',
'customdl', 'customdl',
) )
customsrc = Path('scratch')/'customsrc'/'initools' customsrc = Path('scratch') / 'customsrc' / 'initools'
assert customsrc in result.files_created, ( assert customsrc in result.files_created, (
sorted(result.files_created.keys()) 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()) sorted(result.files_created.keys())
) )
customdl = Path('scratch')/'customdl'/'initools' customdl = Path('scratch') / 'customdl' / 'initools'
customdl_files_created = [ customdl_files_created = [
filename for filename in result.files_created filename for filename in result.files_created
if filename.startswith(customdl) if filename.startswith(customdl)
@ -156,10 +156,10 @@ def test_no_install_followed_by_no_download(script):
--no-download). --no-download).
""" """
egg_info_folder = ( 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' initools_folder = script.site_packages / 'initools'
build_dir = script.venv/'build'/'INITools' build_dir = script.venv / 'build' / 'INITools'
result1 = script.pip( result1 = script.pip(
'install', 'INITools==0.2', '--no-install', expect_error=True, '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) sorted(result1.files_created)
) )
assert build_dir in result1.files_created, 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( result2 = script.pip(
'install', 'INITools==0.2', '--no-download', expect_error=True, '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) sorted(result2.files_created)
) )
assert build_dir not in 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): 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") to_install = data.packages.join("FSPkg")
result = script.pip('install', to_install, expect_error=False) result = script.pip('install', to_install, expect_error=False)
fspkg_folder = script.site_packages/'fspkg' fspkg_folder = script.site_packages / 'fspkg'
egg_info_folder = ( 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 fspkg_folder in result.files_created, str(result.stdout)
assert egg_info_folder in result.files_created, str(result) 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") to_install = data.packages.join("symlinks")
result = script.pip('install', to_install, expect_error=False) result = script.pip('install', to_install, expect_error=False)
pkg_folder = script.site_packages/'symlinks' pkg_folder = script.site_packages / 'symlinks'
egg_info_folder = ( 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 pkg_folder in result.files_created, str(result.stdout)
assert egg_info_folder in result.files_created, str(result) 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") to_install = data.packages.join("FSPkg")
result = script.pip('install', to_install, '--egg', expect_error=False) result = script.pip('install', to_install, '--egg', expect_error=False)
fspkg_folder = script.site_packages/'fspkg' fspkg_folder = script.site_packages / 'fspkg'
egg_folder = script.site_packages/'FSPkg-0.1dev-py%s.egg' % pyversion egg_folder = script.site_packages / 'FSPkg-0.1dev-py%s.egg' % pyversion
assert fspkg_folder not in result.files_created, str(result.stdout) assert fspkg_folder not in result.files_created, str(result.stdout)
assert egg_folder in result.files_created, str(result) assert egg_folder in result.files_created, str(result)
assert join(egg_folder, 'fspkg') 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): if os.path.isdir(egg_info):
rmtree(egg_info) rmtree(egg_info)
result = script.pip('install', curdir, cwd=run_from, expect_error=False) 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 = ( 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 fspkg_folder in result.files_created, str(result.stdout)
assert egg_info_folder in result.files_created, str(result) 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") run_from = data.packages.join("FSPkg", "fspkg")
result = script.pip('install', pardir, cwd=run_from, expect_error=False) 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 = ( 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 fspkg_folder in result.files_created, str(result.stdout)
assert egg_info_folder in result.files_created, str(result) 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 '--install-option=--script-dir=%s' % folder
) )
virtualenv_bin = ( 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 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 Test installing a folder using pip install ./foldername
""" """
script.scratch_path.join("mock").mkdir() 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) pkg_path.join("setup.py").write(mock100_setup_py)
result = script.pip('install', './mock') result = script.pip('install', './mock')
egg_folder = script.site_packages / 'mock-100.1-py%s.egg-info' % pyversion 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\ Test installing a folder using pip install foldername/ or foldername\
""" """
script.scratch_path.join("mock").mkdir() 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) pkg_path.join("setup.py").write(mock100_setup_py)
result = script.pip('install', 'mock' + os.path.sep) result = script.pip('install', 'mock' + os.path.sep)
egg_folder = script.site_packages / 'mock-100.1-py%s.egg-info' % pyversion 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").mkdir()
script.scratch_path.join("initools", "mock").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) 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 egg_folder = script.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
assert egg_folder in result.files_created, str(result) 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 Test installing package from pypi which contains 'dev' in name
""" """
result = script.pip('install', 'django-devserver==0.0.4') result = script.pip('install', 'django-devserver==0.0.4')
devserver_folder = script.site_packages/'devserver' devserver_folder = script.site_packages / 'devserver'
egg_info_folder = ( 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 devserver_folder in result.files_created, str(result.stdout)
assert egg_info_folder in result.files_created, str(result) 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 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") 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) str(result)
) )
@ -530,7 +531,7 @@ def test_install_package_with_root(script, data):
""" """
Test installing a package using pip install --root Test installing a package using pip install --root
""" """
root_dir = script.scratch_path/'root' root_dir = script.scratch_path / 'root'
result = script.pip( result = script.pip(
'install', '--root', root_dir, '-f', data.find_links, '--no-index', 'install', '--root', root_dir, '-f', data.find_links, '--no-index',
'simple==1.0', '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 # There are many locations for the __init__.pyc file so attempt to find
# any of them # any of them
exists = [ exists = [
os.path.exists(script.site_packages_path/"initools/__init__.pyc"), os.path.exists(script.site_packages_path / "initools/__init__.pyc"),
] ]
exists += glob.glob( exists += glob.glob(
script.site_packages_path/"initools/__pycache__/__init__*.pyc" script.site_packages_path / "initools/__pycache__/__init__*.pyc"
) )
assert any(exists) 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 # There are many locations for the __init__.pyc file so attempt to find
# any of them # any of them
exists = [ exists = [
os.path.exists(script.site_packages_path/"initools/__init__.pyc"), os.path.exists(script.site_packages_path / "initools/__init__.pyc"),
] ]
exists += glob.glob( exists += glob.glob(
script.site_packages_path/"initools/__pycache__/__init__*.pyc" script.site_packages_path / "initools/__pycache__/__init__*.pyc"
) )
assert not any(exists) assert not any(exists)

View File

@ -15,8 +15,8 @@ def test_cleanup_after_install(script, data):
script.pip( script.pip(
'install', '--no-index', '--find-links=%s' % data.find_links, 'simple' 'install', '--no-index', '--find-links=%s' % data.find_links, 'simple'
) )
build = script.venv_path/"build" build = script.venv_path / "build"
src = script.venv_path/"src" src = script.venv_path / "src"
assert not exists(build), "build/ dir still exists: %s" % build assert not exists(build), "build/ dir still exists: %s" % build
assert not exists(src), "unexpected src/ dir exists: %s" % src assert not exists(src), "unexpected src/ dir exists: %s" % src
script.assert_no_temp() script.assert_no_temp()
@ -30,7 +30,7 @@ def test_no_clean_option_blocks_cleaning_after_install(script, data):
'install', '--no-clean', '--no-index', 'install', '--no-clean', '--no-index',
'--find-links=%s' % data.find_links, 'simple' '--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) 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, expect_error=True,
) )
build = script.venv_path/'build' build = script.venv_path / 'build'
src = script.venv_path/'src' src = script.venv_path / 'src'
assert not exists(build), "build/ dir still exists: %s" % build assert not exists(build), "build/ dir still exists: %s" % build
assert exists(src), "expected src/ dir doesn't exist: %s" % src assert exists(src), "expected src/ dir doesn't exist: %s" % src
script.assert_no_temp() script.assert_no_temp()
@ -62,8 +62,8 @@ def test_cleanup_after_install_from_local_directory(script, data):
""" """
to_install = data.packages.join("FSPkg") to_install = data.packages.join("FSPkg")
script.pip('install', to_install, expect_error=False) script.pip('install', to_install, expect_error=False)
build = script.venv_path/'build' build = script.venv_path / 'build'
src = script.venv_path/'src' src = script.venv_path / 'src'
assert not exists(build), "unexpected build/ dir exists: %s" % build assert not exists(build), "unexpected build/ dir exists: %s" % build
assert not exists(src), "unexpected src/ dir exist: %s" % src assert not exists(src), "unexpected src/ dir exist: %s" % src
script.assert_no_temp() 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 It should remove build/ dir if it was pip that created
""" """
script.scratch_path.join("downloaded_packages").mkdir() 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( result = script.pip(
'install', '--no-install', 'INITools==0.2', '-d', 'downloaded_packages' 'install', '--no-install', 'INITools==0.2', '-d', 'downloaded_packages'
) )
assert ( assert (
Path('scratch')/'downloaded_packages/build' Path('scratch') / 'downloaded_packages/build'
not in result.files_created not in result.files_created
), 'pip should not leave build/ dir' ), '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" "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)
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 assert not exists(build), "unexpected build/ dir exists: %s" % build
script.assert_no_temp() 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").mkdir()
script.venv_path.join("build", "somefile.txt").write("I am not empty!") script.venv_path.join("build", "somefile.txt").write("I am not empty!")
script.pip('install', '--no-install', 'INITools==0.2', '-d', '.') 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() 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" "build/ should be left if it exists before pip run"
) )
assert content == 'I am not empty!', ( assert content == 'I am not empty!', (
"it should not affect build/ and its content" "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): 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', 'install', '-f', data.find_links, '--no-index', 'broken==0.2broken',
expect_error=True, expect_error=True,
) )
build = script.venv_path/'build' build = script.venv_path / 'build'
assert not exists(build), "build/ dir still exists: %s" % result.stdout assert not exists(build), "build/ dir still exists: %s" % result.stdout
script.assert_no_temp() 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', 'install', '-f', data.find_links, '--no-index', 'brokenegginfo==0.1',
expect_error=True, expect_error=True,
) )
build = script.venv_path/'build' build = script.venv_path / 'build'
assert not exists(build), "build/ dir still exists: %s" % result.stdout assert not exists(build), "build/ dir still exists: %s" % result.stdout
script.assert_no_temp() 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 Test no cleanup occurs after a PreviousBuildDirError
""" """
build = script.venv_path/'build'/'simple' build = script.venv_path / 'build' / 'simple'
os.makedirs(build) os.makedirs(build)
write_delete_marker_file(script.venv_path/'build') write_delete_marker_file(script.venv_path / 'build')
build.join("setup.py").write("#") build.join("setup.py").write("#")
result = script.pip( result = script.pip(
'install', '-f', data.find_links, '--no-index', 'simple', 'install', '-f', data.find_links, '--no-index', 'simple',

View File

@ -41,7 +41,7 @@ def test_debian_egg_name_workaround(script):
# Try the uninstall and verify that everything is removed. # Try the uninstall and verify that everything is removed.
result2 = script.pip("uninstall", "INITools", "-y") 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): def test_setup_py_with_dos_line_endings(script, data):

View File

@ -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 # 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 # 'config-item' and 'config_item' hash to the same value modulo the size
# of the config dictionary. # of the config dictionary.
(script.scratch_path/config_file).write(textwrap.dedent("""\ (script.scratch_path / config_file).write(textwrap.dedent("""\
[global] [global]
no-index = 1 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): def _test_config_file_override_stack(script, virtualenv, config_file):
# set this to make pip load it # set this to make pip load it
script.environ['PIP_CONFIG_FILE'] = config_file script.environ['PIP_CONFIG_FILE'] = config_file
(script.scratch_path/config_file).write(textwrap.dedent("""\ (script.scratch_path / config_file).write(textwrap.dedent("""\
[global] [global]
index-url = http://download.zope.org/ppix 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 "Getting page http://download.zope.org/ppix/INITools" in result.stdout
) )
virtualenv.clear() virtualenv.clear()
(script.scratch_path/config_file).write(textwrap.dedent("""\ (script.scratch_path / config_file).write(textwrap.dedent("""\
[global] [global]
index-url = http://download.zope.org/ppix index-url = http://download.zope.org/ppix
[install] [install]

View File

@ -65,9 +65,9 @@ def test_file_index_url_quoting(script, data):
'install', '-vvv', '--index-url', index_url, 'simple', 'install', '-vvv', '--index-url', index_url, 'simple',
expect_error=False, expect_error=False,
) )
assert (script.site_packages/'simple') in result.files_created, ( assert (script.site_packages / 'simple') in result.files_created, (
str(result.stdout) str(result.stdout)
) )
assert ( 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) ) in result.files_created, str(result)

View File

@ -23,13 +23,13 @@ def test_requirements_file(script):
'install', '-r', script.scratch_path / 'initools-req.txt' 'install', '-r', script.scratch_path / 'initools-req.txt'
) )
assert ( 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 pyversion in result.files_created
) )
assert script.site_packages/'initools' 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 result.files_created[script.site_packages / other_lib_name].dir
fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion) 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): 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' 'install', '-vvv', '-r', script.scratch_path / 'file-egg-req.txt'
) )
assert ( 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) ) 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) str(result.stdout)
) )
@ -98,10 +98,10 @@ def test_multiple_requirements_files(script, tmpdir):
result = script.pip( result = script.pip(
'install', '-r', script.scratch_path / 'initools-req.txt' '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) 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
assert script.venv/'src'/'initools' in result.files_created assert script.venv / 'src' / 'initools' in result.files_created
def test_respect_order_in_requirements_file(script, data): 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', 'install', '-e', to_install + '[bar]', '--process-dependency-links',
expect_error=False, 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) str(res)
) )
assert script.site_packages/'LocalExtras.egg-link' in res.files_created, ( assert (
str(res) 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 / 'simple' in res.files_created, str(res)
def test_install_local_editable_with_subdirectory(script): def test_install_local_editable_with_subdirectory(script):

View File

@ -34,11 +34,11 @@ def test_upgrade_to_specific_version(script):
'pip install with specific version did not upgrade' 'pip install with specific version did not upgrade'
) )
assert ( 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 pyversion in result.files_deleted
) )
assert ( 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 pyversion in result.files_created
) )
@ -52,7 +52,7 @@ def test_upgrade_if_requested(script):
result = script.pip('install', '--upgrade', 'INITools', expect_error=True) result = script.pip('install', '--upgrade', 'INITools', expect_error=True)
assert result.files_created, 'pip install --upgrade did not upgrade' assert result.files_created, 'pip install --upgrade did not upgrade'
assert ( 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 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' assert result2.files_updated, 'upgrade to INITools 0.3 failed'
result3 = script.pip('uninstall', 'initools', '-y', expect_error=True) 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): 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) result2 = script.pip('install', 'INITools==0.3', expect_error=True)
assert result2.files_created, 'upgrade to INITools 0.3 failed' assert result2.files_created, 'upgrade to INITools 0.3 failed'
result3 = script.pip('uninstall', 'initools', '-y', expect_error=True) 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): 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' assert result2.files_created, 'upgrade to INITools 0.3 failed'
result3 = script.pip('uninstall', 'initools', '-y', expect_error=True) 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): 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' assert not result2.files_updated, 'INITools 0.3 reinstalled same version'
result3 = script.pip('uninstall', 'initools', '-y', expect_error=True) 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): def test_upgrade_from_reqs_file(script):
@ -170,7 +170,7 @@ def test_upgrade_from_reqs_file(script):
assert_all_changes( assert_all_changes(
install_result, install_result,
uninstall_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( assert_all_changes(
result.files_after, result.files_after,
result2, 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') script.pip('uninstall', '-y', 'INITools')
result = script.pip('install', 'INITools==0.1', expect_error=True) result = script.pip('install', 'INITools==0.1', expect_error=True)
assert ( 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 pyversion not in result.files_created
) )
assert ( 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 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' assert result.files_created, 'pip install -I did not install'
# both the old and new metadata should be present. # both the old and new metadata should be present.
assert os.path.exists( 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( 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): def prep_ve(self, script, version, pip_src, distribute=False):
self.script = script self.script = script
self.script.pip_install_local('virtualenv==%s' % version) self.script.pip_install_local('virtualenv==%s' % version)
args = ['virtualenv', self.script.scratch_path/'VE'] args = ['virtualenv', self.script.scratch_path / 'VE']
if distribute: if distribute:
args.insert(1, '--distribute') args.insert(1, '--distribute')
if version == "1.9.1" and not distribute: if version == "1.9.1" and not distribute:
@ -309,10 +309,10 @@ class TestUpgradeSetuptools(object):
bindir = "Scripts" bindir = "Scripts"
else: else:
bindir = "bin" bindir = "bin"
self.ve_bin = self.script.scratch_path/'VE'/bindir 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 / 'pip', 'uninstall', '-y', 'pip')
self.script.run( self.script.run(
self.ve_bin/'python', 'setup.py', 'install', self.ve_bin / 'python', 'setup.py', 'install',
cwd=pip_src, cwd=pip_src,
expect_stderr=True, expect_stderr=True,
) )
@ -322,13 +322,13 @@ class TestUpgradeSetuptools(object):
self, script, data, virtualenv): self, script, data, virtualenv):
self.prep_ve(script, '1.9.1', virtualenv.pip_source_dir) self.prep_ve(script, '1.9.1', virtualenv.pip_source_dir)
result = self.script.run( 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' '--find-links=%s' % data.find_links, '-U', 'setuptools'
) )
assert ( assert (
"Found existing installation: setuptools 0.6c11" in result.stdout "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 "setuptools (0.9.8)" in result.stdout
def test_py2_py3_from_distribute_6_to_setuptools_7( 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 script, '1.9.1', virtualenv.pip_source_dir, distribute=True
) )
result = self.script.run( 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' '--find-links=%s' % data.find_links, '-U', 'setuptools'
) )
assert ( assert (
"Found existing installation: distribute 0.6.34" in result.stdout "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 "setuptools (0.9.8)" in result.stdout
"distribute (0.7.3)" in result.stdout "distribute (0.7.3)" in result.stdout
def test_from_setuptools_7_to_setuptools_7(self, script, data, virtualenv): def test_from_setuptools_7_to_setuptools_7(self, script, data, virtualenv):
self.prep_ve(script, '1.10', virtualenv.pip_source_dir) self.prep_ve(script, '1.10', virtualenv.pip_source_dir)
result = self.script.run( 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' '--find-links=%s' % data.find_links, '-U', 'setuptools'
) )
assert "Found existing installation: setuptools 0.9.7" in result.stdout 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 "setuptools (0.9.8)" in result.stdout
def test_from_setuptools_7_to_setuptools_7_using_wheel( def test_from_setuptools_7_to_setuptools_7_using_wheel(
self, script, data, virtualenv): self, script, data, virtualenv):
self.prep_ve(script, '1.10', virtualenv.pip_source_dir) self.prep_ve(script, '1.10', virtualenv.pip_source_dir)
result = self.script.run( 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' '--find-links=%s' % data.find_links, '-U', 'setuptools'
) )
assert "Found existing installation: setuptools 0.9.7" in result.stdout assert "Found existing installation: setuptools 0.9.7" in result.stdout
# only wheels use dist-info # only wheels use dist-info
assert 'setuptools-0.9.8.dist-info' in str(result.files_created) 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 "setuptools (0.9.8)" in result.stdout
# disabling intermittent travis failure: # disabling intermittent travis failure:
@ -379,21 +379,21 @@ class TestUpgradeSetuptools(object):
script, '1.9.1', virtualenv.pip_source_dir, distribute=True script, '1.9.1', virtualenv.pip_source_dir, distribute=True
) )
result = self.script.run( 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' '--find-links=%s' % data.find_links, '-U', 'setuptools'
) )
result = self.script.run( 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' '--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 "setuptools (0.9.6)" in result.stdout
"distribute (0.7.3)" in result.stdout "distribute (0.7.3)" in result.stdout
result = self.script.run( 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' '--find-links=%s' % data.find_links, '-U', 'setuptools'
) )
assert "Found existing installation: setuptools 0.9.6" in result.stdout 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 "setuptools (0.9.8)" in result.stdout
"distribute (0.7.3)" in result.stdout "distribute (0.7.3)" in result.stdout

View File

@ -85,9 +85,9 @@ class Tests_UserSite:
cwd=run_from, cwd=run_from,
expect_error=False, expect_error=False,
) )
fspkg_folder = script.user_site/'fspkg' fspkg_folder = script.user_site / 'fspkg'
egg_info_folder = ( 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 assert fspkg_folder in result.files_created, result.stdout
@ -124,7 +124,8 @@ class Tests_UserSite:
) )
initools_v3_file = ( initools_v3_file = (
# file only in 0.3 # 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 egg_info_folder in result2.files_created, str(result2)
assert not isfile(initools_v3_file), initools_v3_file assert not isfile(initools_v3_file), initools_v3_file
@ -245,7 +246,8 @@ class Tests_UserSite:
) )
initools_v3_file = ( initools_v3_file = (
# file only in 0.3 # 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 egg_info_folder in result3.files_created, str(result3)
assert not isfile(initools_v3_file), initools_v3_file assert not isfile(initools_v3_file), initools_v3_file

View File

@ -113,7 +113,7 @@ def test_git_branch_should_not_be_changed(script, tmpdir):
), ),
expect_error=True, 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) result = script.run('git', 'branch', cwd=source_dir)
assert '* master' in result.stdout, result.stdout 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' % '%s#egg=django-devserver' %
local_checkout( local_checkout(
'git+git://github.com/dcramer/django-devserver.git', 'git+git://github.com/dcramer/django-devserver.git',
tmpdir.join("cache")) tmpdir.join("cache")
) )
)
result.assert_installed('django-devserver', with_files=['.git']) 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' % '%s#egg=django-devserver' %
local_checkout( local_checkout(
'git+git://github.com/dcramer/django-devserver.git', 'git+git://github.com/dcramer/django-devserver.git',
tmpdir.join("cache")), tmpdir.join("cache")
) ),
devserver_folder = script.site_packages/'devserver' )
devserver_folder = script.site_packages / 'devserver'
assert devserver_folder in result.files_created, str(result) assert devserver_folder in result.files_created, str(result)

View File

@ -8,7 +8,7 @@ from tests.lib.git_submodule_helpers import (
_change_test_package_submodule, _change_test_package_submodule,
_pull_in_submodule_changes_to_module, _pull_in_submodule_changes_to_module,
_create_test_package_with_submodule, _create_test_package_with_submodule,
) )
def test_get_refs_should_return_tag_name_and_commit_pair(script): 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) module_path, submodule_path = _create_test_package_with_submodule(script)
install_result = script.pip( install_result = script.pip(
'install', '-e', 'git+'+module_path+'#egg=version_pkg' 'install', '-e', 'git+' + module_path + '#egg=version_pkg'
) )
assert ( assert (
script.venv/'src/version-pkg/testpkg/static/testfile' script.venv / 'src/version-pkg/testpkg/static/testfile'
in install_result.files_created in install_result.files_created
) )
@ -105,11 +105,12 @@ def test_check_submodule_addition(script):
# expect error because git may write to stderr # expect error because git may write to stderr
update_result = script.pip( 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, expect_error=True,
) )
assert ( assert (
script.venv/'src/version-pkg/testpkg/static/testfile2' script.venv / 'src/version-pkg/testpkg/static/testfile2'
in update_result.files_created in update_result.files_created
) )

View File

@ -5,22 +5,22 @@ from pip.vcs.subversion import Subversion
@patch('pip.vcs.subversion.call_subprocess') @patch('pip.vcs.subversion.call_subprocess')
def test_obtain_should_recognize_auth_info_url(call_subprocess_mock, script): def test_obtain_should_recognize_auth_info_url(call_subprocess_mock, script):
svn = Subversion(url='svn+http://username:password@svn.example.com/') 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([ call_subprocess_mock.assert_called_with([
svn.cmd, 'checkout', '-q', '--username', 'username', '--password', svn.cmd, 'checkout', '-q', '--username', 'username', '--password',
'password', 'http://username:password@svn.example.com/', 'password', 'http://username:password@svn.example.com/',
script.scratch_path/'test', script.scratch_path / 'test',
]) ])
@patch('pip.vcs.subversion.call_subprocess') @patch('pip.vcs.subversion.call_subprocess')
def test_export_should_recognize_auth_info_url(call_subprocess_mock, script): def test_export_should_recognize_auth_info_url(call_subprocess_mock, script):
svn = Subversion(url='svn+http://username:password@svn.example.com/') 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] == ( assert call_subprocess_mock.call_args[0] == (
[ [
svn.cmd, 'export', '--username', 'username', '--password', svn.cmd, 'export', '--username', 'username', '--password',
'password', 'http://username:password@svn.example.com/', 'password', 'http://username:password@svn.example.com/',
script.scratch_path/'test', script.scratch_path / 'test',
], ],
) )

View File

@ -39,10 +39,10 @@ def test_install_from_wheel(script, data):
""" """
result = script.pip( result = script.pip(
'install', 'has.script==1.0', '--use-wheel', '--no-index', 'install', 'has.script==1.0', '--use-wheel', '--no-index',
'--find-links='+data.find_links, '--find-links=' + data.find_links,
expect_error=False, 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, assert dist_info_folder in result.files_created, (dist_info_folder,
result.files_created, result.files_created,
result.stdout) result.stdout)
@ -56,14 +56,14 @@ def test_install_from_wheel_with_extras(script, data):
""" """
result = script.pip( result = script.pip(
'install', 'complex-dist[simple]', '--use-wheel', '--no-index', 'install', 'complex-dist[simple]', '--use-wheel', '--no-index',
'--find-links='+data.find_links, '--find-links=' + data.find_links,
expect_error=False, 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, assert dist_info_folder in result.files_created, (dist_info_folder,
result.files_created, result.files_created,
result.stdout) 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, assert dist_info_folder in result.files_created, (dist_info_folder,
result.files_created, result.files_created,
result.stdout) 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") package = data.packages.join("simple.dist-0.1-py2.py3-none-any.whl")
result = script.pip('install', package, '--no-index', expect_error=False) 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, assert dist_info_folder in result.files_created, (dist_info_folder,
result.files_created, result.files_created,
result.stdout) 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") package = data.packages.join("headers.dist-0.1-py2.py3-none-any.whl")
result = script.pip('install', package, '--no-index', expect_error=False) 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, assert dist_info_folder in result.files_created, (dist_info_folder,
result.files_created, result.files_created,
result.stdout) result.stdout)
@ -101,12 +101,12 @@ def test_install_wheel_with_target(script, data):
Test installing a wheel using pip install --target Test installing a wheel using pip install --target
""" """
script.pip('install', 'wheel') script.pip('install', 'wheel')
target_dir = script.scratch_path/'target' target_dir = script.scratch_path / 'target'
result = script.pip( result = script.pip(
'install', 'simple.dist==0.1', '-t', target_dir, '--use-wheel', '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) str(result)
) )
@ -115,12 +115,12 @@ def test_install_wheel_with_root(script, data):
""" """
Test installing a wheel using pip install --root Test installing a wheel using pip install --root
""" """
root_dir = script.scratch_path/'root' root_dir = script.scratch_path / 'root'
result = script.pip( result = script.pip(
'install', 'simple.dist==0.1', '--root', root_dir, '--use-wheel', '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): 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', 'install', '--no-index', '--find-links', data.find_links, '--no-deps',
package, package,
) )
pkg_folder = script.site_packages/'source' pkg_folder = script.site_packages / 'source'
assert pkg_folder not in result.files_created assert pkg_folder not in result.files_created
@ -159,7 +159,7 @@ def test_install_user_wheel(script, virtualenv, data):
script.pip('install', 'wheel') script.pip('install', 'wheel')
result = script.pip( result = script.pip(
'install', 'has.script==1.0', '--user', '--use-wheel', '--no-index', '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' egg_info_folder = script.user_site / 'has.script-1.0.dist-info'
assert egg_info_folder in result.files_created, str(result) 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( result = script.pip(
'install', 'script.wheel1a==0.1', '--use-wheel', '--no-index', 'install', 'script.wheel1a==0.1', '--use-wheel', '--no-index',
'--find-links='+data.find_links, '--find-links=' + data.find_links,
expect_error=False, expect_error=False,
) )
if os.name == 'nt': if os.name == 'nt':
@ -192,7 +192,7 @@ def test_install_from_wheel_with_legacy(script, data):
""" """
result = script.pip( result = script.pip(
'install', 'script.wheel2a==0.1', '--use-wheel', '--no-index', 'install', 'script.wheel2a==0.1', '--use-wheel', '--no-index',
'--find-links='+data.find_links, '--find-links=' + data.find_links,
expect_error=False, expect_error=False,
) )
@ -210,7 +210,7 @@ def test_install_from_wheel_no_setuptools_entrypoint(script, data):
""" """
result = script.pip( result = script.pip(
'install', 'script.wheel1==0.1', '--use-wheel', '--no-index', 'install', 'script.wheel1==0.1', '--use-wheel', '--no-index',
'--find-links='+data.find_links, '--find-links=' + data.find_links,
expect_error=False, expect_error=False,
) )
if os.name == 'nt': if os.name == 'nt':
@ -235,7 +235,7 @@ def test_skipping_setuptools_doesnt_skip_legacy(script, data):
""" """
result = script.pip( result = script.pip(
'install', 'script.wheel2==0.1', '--use-wheel', '--no-index', 'install', 'script.wheel2==0.1', '--use-wheel', '--no-index',
'--find-links='+data.find_links, '--find-links=' + data.find_links,
expect_error=False, expect_error=False,
) )
@ -254,7 +254,7 @@ def test_install_from_wheel_gui_entrypoint(script, data):
""" """
result = script.pip( result = script.pip(
'install', 'script.wheel3==0.1', '--use-wheel', '--no-index', 'install', 'script.wheel3==0.1', '--use-wheel', '--no-index',
'--find-links='+data.find_links, '--find-links=' + data.find_links,
expect_error=False, expect_error=False,
) )
if os.name == 'nt': 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 # There are many locations for the __init__.pyc file so attempt to find
# any of them # any of them
exists = [ exists = [
os.path.exists(script.site_packages_path/"simpledist/__init__.pyc"), os.path.exists(script.site_packages_path / "simpledist/__init__.pyc"),
] ]
exists += glob.glob( exists += glob.glob(
script.site_packages_path/"simpledist/__pycache__/__init__*.pyc" script.site_packages_path / "simpledist/__pycache__/__init__*.pyc"
) )
assert any(exists) 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 # There are many locations for the __init__.pyc file so attempt to find
# any of them # any of them
exists = [ exists = [
os.path.exists(script.site_packages_path/"simpledist/__init__.pyc"), os.path.exists(script.site_packages_path / "simpledist/__init__.pyc"),
] ]
exists += glob.glob( exists += glob.glob(
script.site_packages_path/"simpledist/__pycache__/__init__*.pyc" script.site_packages_path / "simpledist/__pycache__/__init__*.pyc"
) )
assert not any(exists) assert not any(exists)

View File

@ -25,7 +25,7 @@ def test_simple_uninstall(script):
# supports it # supports it
script.run('python', '-c', "import initools") script.run('python', '-c', "import initools")
result2 = script.pip('uninstall', 'INITools', '-y') 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): def test_uninstall_with_scripts(script):
@ -41,7 +41,7 @@ def test_uninstall_with_scripts(script):
assert_all_changes( assert_all_changes(
result, result,
result2, 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( assert_all_changes(
result, result,
result2, 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 = ['install']
args.append('discover') args.append('discover')
result = script.pip(*args, **{"expect_error": True}) 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()) sorted(result.files_created.keys())
) )
result2 = script.pip('uninstall', 'discover', '-y', expect_error=True) 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): def test_uninstall_easy_installed_console_scripts(script):
@ -143,14 +147,18 @@ def test_uninstall_easy_installed_console_scripts(script):
args = ['easy_install'] args = ['easy_install']
args.append('discover') args.append('discover')
result = script.run(*args, **{"expect_stderr": True}) 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()) sorted(result.files_created.keys())
) )
result2 = script.pip('uninstall', 'discover', '-y') result2 = script.pip('uninstall', 'discover', '-y')
assert_all_changes( assert_all_changes(
result, result,
result2, 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') result.assert_installed('INITools')
result2 = script.pip('uninstall', '-y', '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( assert_all_changes(
result, result,
result2, result2,
[ [
script.venv/'src', script.venv / 'src',
script.venv/'build', script.venv / 'build',
script.site_packages/'easy-install.pth' script.site_packages / 'easy-install.pth'
], ],
) )
@ -217,7 +225,7 @@ def _test_uninstall_editable_with_source_outside_venv(
assert_all_changes( assert_all_changes(
result, result,
result3, 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, result,
result2, result2,
[ [
script.venv/'build', script.venv / 'build',
script.venv/'src', script.venv / 'src',
script.scratch/'test-req.txt', script.scratch / 'test-req.txt',
script.site_packages/'easy-install.pth', script.site_packages / 'easy-install.pth',
], ],
) )
@ -273,8 +281,8 @@ def test_uninstall_as_egg(script, data):
""" """
to_install = data.packages.join("FSPkg") to_install = data.packages.join("FSPkg")
result = script.pip('install', to_install, '--egg', expect_error=False) result = script.pip('install', to_install, '--egg', expect_error=False)
fspkg_folder = script.site_packages/'fspkg' fspkg_folder = script.site_packages / 'fspkg'
egg_folder = script.site_packages/'FSPkg-0.1dev-py%s.egg' % pyversion egg_folder = script.site_packages / 'FSPkg-0.1dev-py%s.egg' % pyversion
assert fspkg_folder not in result.files_created, str(result.stdout) assert fspkg_folder not in result.files_created, str(result.stdout)
assert egg_folder in result.files_created, str(result) assert egg_folder in result.files_created, str(result)
@ -283,9 +291,9 @@ def test_uninstall_as_egg(script, data):
result, result,
result2, result2,
[ [
script.venv/'build', script.venv / 'build',
'cache', 'cache',
script.site_packages/'easy-install.pth', script.site_packages / 'easy-install.pth',
], ],
) )

View File

@ -20,7 +20,7 @@ class Tests_UninstallUserSite:
virtualenv.system_site_packages = True virtualenv.system_site_packages = True
result1 = script.pip('install', '--user', 'INITools==0.3') result1 = script.pip('install', '--user', 'INITools==0.3')
result2 = script.pip('uninstall', '-y', 'INITools') 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( def test_uninstall_from_usersite_with_dist_in_global_site(
self, script, virtualenv): self, script, virtualenv):
@ -53,7 +53,7 @@ class Tests_UninstallUserSite:
assert script.bin_path not in result3.stdout assert script.bin_path not in result3.stdout
# uninstall worked # 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) # site still has 0.2 (can't look in result1; have to check)
egg_info_folder = ( egg_info_folder = (
@ -74,7 +74,7 @@ class Tests_UninstallUserSite:
result1 = script.pip( result1 = script.pip(
'install', '--user', '-e', to_install, expect_error=False, '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) assert egg_link in result1.files_created, str(result1.stdout)
#uninstall #uninstall
@ -84,5 +84,9 @@ class Tests_UninstallUserSite:
assert_all_changes( assert_all_changes(
result1, result1,
result2, result2,
[script.venv/'build', 'cache', script.user_site/'easy-install.pth'] [
script.venv / 'build',
'cache',
script.user_site / 'easy-install.pth',
]
) )

View File

@ -31,7 +31,7 @@ def test_pip_wheel_success(script, data):
'wheel', '--no-index', '-f', data.find_links, 'simple==3.0', '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_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 wheel_file_path in result.files_created, result.stdout
assert "Successfully built simple" in result.stdout, 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', '--no-index', '-f', data.find_links, 'simple.dist',
) )
wheel_file_name = 'simple.dist-0.1-py2.py3-none-any.whl' 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 wheel_file_path in result.files_created, result.stdout
assert "Saved" in result.stdout, 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', '--no-index', '-f', data.find_links, 'wheelbroken==0.1',
) )
wheel_file_name = 'wheelbroken-0.1-py%s-none-any.whl' % pyversion_nodot 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, ( assert wheel_file_path not in result.files_created, (
wheel_file_path, wheel_file_path,
result.files_created, result.files_created,
@ -86,7 +86,7 @@ def test_pip_wheel_ignore_wheels_editables(script, data):
script.scratch_path / 'reqs.txt', script.scratch_path / 'reqs.txt',
) )
wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot 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, ( assert wheel_file_path in result.files_created, (
wheel_file_path, wheel_file_path,
result.files_created, result.files_created,
@ -109,7 +109,7 @@ def test_no_clean_option_blocks_cleaning_after_wheel(script, data):
'wheel', '--no-clean', '--no-index', 'wheel', '--no-clean', '--no-index',
'--find-links=%s' % data.find_links, 'simple', '--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) 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', 'requires_source',
) )
wheel_file_name = 'source-1.0-py%s-none-any.whl' % pyversion_nodot 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 wheel_file_path in result.files_created, result.stdout
assert "Successfully built source" in result.stdout, result.stdout assert "Successfully built source" in result.stdout, result.stdout

View File

@ -134,10 +134,10 @@ class TestPipResult(object):
e = self.test_env e = self.test_env
if editable: if editable:
pkg_dir = e.venv/'src'/pkg_name.lower() pkg_dir = e.venv / 'src' / pkg_name.lower()
else: else:
without_egg_link = True without_egg_link = True
pkg_dir = e.site_packages/pkg_name pkg_dir = e.site_packages / pkg_name
if use_user_site: if use_user_site:
egg_link_path = e.user_site / pkg_name + '.egg-link' egg_link_path = e.user_site / pkg_name + '.egg-link'
@ -173,9 +173,9 @@ class TestPipResult(object):
egg_link_file.bytes)))) egg_link_file.bytes))))
if use_user_site: if use_user_site:
pth_file = e.user_site/'easy-install.pth' pth_file = e.user_site / 'easy-install.pth'
else: 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: if (pth_file in self.files_updated) == without_egg_link:
raise TestFailure('%r unexpectedly %supdated by install' % ( raise TestFailure('%r unexpectedly %supdated by install' % (
@ -192,14 +192,14 @@ class TestPipResult(object):
sorted(self.files_created.keys()))) sorted(self.files_created.keys())))
for f in with_files: 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( raise TestFailure(
'Package directory %r missing expected content %r' % 'Package directory %r missing expected content %r' %
(pkg_dir, f) (pkg_dir, f)
) )
for f in without_files: 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( raise TestFailure(
'Package directory %r has unexpected content %f' % 'Package directory %r has unexpected content %f' %
(pkg_dir, 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): def _create_test_package_with_subdirectory(script, subdirectory):
script.scratch_path.join("version_pkg").mkdir() 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(""" version_pkg_path.join("version_pkg.py").write(textwrap.dedent("""
def main(): def main():
print('0.1') print('0.1')
@ -442,7 +442,7 @@ setup(name='version_subpkg',
def _create_test_package(script): def _create_test_package(script):
script.scratch_path.join("version_pkg").mkdir() 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(""" version_pkg_path.join("version_pkg.py").write(textwrap.dedent("""
def main(): def main():
print('0.1') print('0.1')

View File

@ -5,7 +5,7 @@ import textwrap
def _create_test_package_submodule(env): def _create_test_package_submodule(env):
env.scratch_path.join("version_pkg_submodule").mkdir() 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('touch', 'testfile', cwd=submodule_path)
env.run('git', 'init', cwd=submodule_path) env.run('git', 'init', cwd=submodule_path)
env.run('git', 'add', '.', 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', '-q',
'origin', 'origin',
'master', 'master',
cwd=module_path/'testpkg/static/', cwd=module_path / 'testpkg/static/',
) )
env.run('git', 'commit', '-q', env.run('git', 'commit', '-q',
'--author', 'Pip <python-virtualenv@googlegroups.com>', '--author', 'Pip <python-virtualenv@googlegroups.com>',
@ -40,9 +40,9 @@ def _pull_in_submodule_changes_to_module(env, module_path):
def _create_test_package_with_submodule(env): def _create_test_package_with_submodule(env):
env.scratch_path.join("version_pkg").mkdir() 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() 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("__init__.py").write("# hello there")
pkg_path.join("version_pkg.py").write(textwrap.dedent('''\ pkg_path.join("version_pkg.py").write(textwrap.dedent('''\

View File

@ -55,7 +55,9 @@ def _get_vcs_and_checkout_url(remote_repository, directory):
if vcs == 'svn': if vcs == 'svn':
branch = os.path.basename(remote_repository) branch = os.path.basename(remote_repository)
# remove the slash # remove the slash
repository_name = os.path.basename(remote_repository[:-len(branch)-1]) repository_name = os.path.basename(
remote_repository[:-len(branch) - 1]
)
else: else:
repository_name = os.path.basename(remote_repository) repository_name = os.path.basename(remote_repository)

View File

@ -262,7 +262,7 @@ class Test_unpack_file_url(object):
self.dist_url.url = "%s#md5=%s" % ( self.dist_url.url = "%s#md5=%s" % (
self.dist_url.url, self.dist_url.url,
dist_path_md5 dist_path_md5
) )
unpack_file_url(self.dist_url, self.build_dir, unpack_file_url(self.dist_url, self.build_dir,
download_dir=self.download_dir) download_dir=self.download_dir)

View File

@ -76,8 +76,8 @@ def test_finder_detects_latest_already_satisfied_pypi_links():
satisfied_by = Mock( satisfied_by = Mock(
location="/path", location="/path",
parsed_version=parse_version(latest_version), parsed_version=parse_version(latest_version),
version=latest_version version=latest_version,
) )
req.satisfied_by = satisfied_by req.satisfied_by = satisfied_by
finder = PackageFinder([], ["http://pypi.python.org/simple"]) finder = PackageFinder([], ["http://pypi.python.org/simple"])
@ -156,8 +156,8 @@ class TestWheel:
satisfied_by = Mock( satisfied_by = Mock(
location="/path", location="/path",
parsed_version=parse_version(latest_version), parsed_version=parse_version(latest_version),
version=latest_version version=latest_version,
) )
req.satisfied_by = satisfied_by req.satisfied_by = satisfied_by
finder = PackageFinder([data.find_links], [], use_wheel=True) finder = PackageFinder([data.find_links], [], use_wheel=True)

View File

@ -38,15 +38,15 @@ class TestOptionPrecedence(object):
def get_config_section(self, section): def get_config_section(self, section):
config = { config = {
'global': [('timeout', '-3')], 'global': [('timeout', '-3')],
'fake': [('timeout', '-2')] 'fake': [('timeout', '-2')],
} }
return config[section] return config[section]
def get_config_section_global(self, section): def get_config_section_global(self, section):
config = { config = {
'global': [('timeout', '-3')], 'global': [('timeout', '-3')],
'fake': [] 'fake': [],
} }
return config[section] return config[section]
def test_env_override_default_int(self): def test_env_override_default_int(self):

View File

@ -33,8 +33,8 @@ class TestRequirementSet(object):
build_dir=os.path.join(self.tempdir, 'build'), build_dir=os.path.join(self.tempdir, 'build'),
src_dir=os.path.join(self.tempdir, 'src'), src_dir=os.path.join(self.tempdir, 'src'),
download_dir=None, 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): def test_no_reuse_existing_build_dir(self, data):
"""Test prepare_files raise exception with previous build dir""" """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" % "pip can't proceed with [\s\S]*%s[\s\S]*%s" %
(req, build_dir.replace('\\', '\\\\')), (req, build_dir.replace('\\', '\\\\')),
reqset.prepare_files, reqset.prepare_files,
finder finder,
) )
@pytest.mark.parametrize(('file_contents', 'expected'), [ @pytest.mark.parametrize(('file_contents', 'expected'), [

View File

@ -213,13 +213,13 @@ def test_find_command_folder_in_path(script):
looking. looking.
""" """
script.scratch_path.join("path_one").mkdir() 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() path_one.join("foo").mkdir()
script.scratch_path.join("path_two").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") path_two.join("foo").write("# nothing")
found_path = find_command('foo', map(str, [path_one, path_two])) 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(): 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_group.sh', 0o755, os.path.isfile),
('script_world.sh', 0o755, os.path.isfile), ('script_world.sh', 0o755, os.path.isfile),
('dir', 0o755, os.path.isdir), ('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) path = os.path.join(self.tempdir, fname)
if path.endswith('symlink.txt') and sys.platform == 'win32': if path.endswith('symlink.txt') and sys.platform == 'win32':
# no symlinks created on windows # no symlinks created on windows

View File

@ -31,3 +31,4 @@ commands = flake8 .
[flake8] [flake8]
exclude = .tox,*.egg,build,_vendor,data exclude = .tox,*.egg,build,_vendor,data
select = E,W,F