Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use Flake8 on the test of pip's Python files

  • Loading branch information...
commit 9f027337a8f54ab411848b90f98533a7855dac4d 1 parent 9efff55
Donald Stufft dstufft authored
Showing with 2,305 additions and 1,015 deletions.
  1. +1 −1  contrib/build-installer
  2. +1 −1  contrib/get-pip.py
  3. +15 −10 docs/conf.py
  4. +14 −4 docs/pipext.py
  5. +44 −38 setup.py
  6. +3 −1 tests/conftest.py
  7. +49 −13 tests/functional/test_bundle.py
  8. +4 −2 tests/functional/test_completion.py
  9. +168 −68 tests/functional/test_freeze.py
  10. +7 −3 tests/functional/test_help.py
  11. +222 −104 tests/functional/test_install.py
  12. +52 −19 tests/functional/test_install_cleanup.py
  13. +3 −2 tests/functional/test_install_compat.py
  14. +59 −18 tests/functional/test_install_config.py
  15. +49 −26 tests/functional/test_install_download.py
  16. +12 −4 tests/functional/test_install_extras.py
  17. +22 −9 tests/functional/test_install_index.py
  18. +74 −38 tests/functional/test_install_reqs.py
  19. +179 −60 tests/functional/test_install_upgrade.py
  20. +142 −60 tests/functional/test_install_user.py
  21. +96 −33 tests/functional/test_install_vcs.py
  22. +32 −14 tests/functional/test_install_vcs_git.py
  23. +11 −5 tests/functional/test_install_vcs_svn.py
  24. +63 −31 tests/functional/test_install_wheel.py
  25. +37 −17 tests/functional/test_list.py
  26. +10 −3 tests/functional/test_requests.py
  27. +70 −15 tests/functional/test_search.py
  28. +163 −57 tests/functional/test_uninstall.py
  29. +28 −20 tests/functional/test_uninstall_user.py
  30. +40 −12 tests/functional/test_wheel.py
  31. +67 −42 tests/lib/__init__.py
  32. +20 −5 tests/lib/git_submodule_helpers.py
  33. +15 −4 tests/lib/local_repos.py
  34. +1 −0  tests/lib/path.py
  35. +1 −1  tests/lib/scripttest.py
  36. +20 −9 tests/lib/test_lib.py
  37. +3 −1 tests/lib/venv.py
  38. +29 −11 tests/scripts/test_all_pip.py
  39. +4 −1 tests/unit/test_backwardcompat.py
  40. +6 −2 tests/unit/test_basecommand.py
  41. +12 −4 tests/unit/test_download.py
  42. +84 −22 tests/unit/test_download_hashes.py
  43. +122 −73 tests/unit/test_finder.py
  44. +17 −17 tests/unit/test_index.py
  45. +29 −26 tests/unit/test_locations.py
  46. +6 −4 tests/unit/test_log.py
  47. +47 −17 tests/unit/test_options.py
  48. +50 −24 tests/unit/test_req.py
  49. +53 −35 tests/unit/test_util.py
  50. +36 −13 tests/unit/test_vcs.py
  51. +13 −16 tests/unit/test_wheel.py
2  contrib/build-installer
View
@@ -54,7 +54,7 @@ def bootstrap(tmpdir=None):
# We want to see if setuptools is available before attempting to
# install it
try:
- import setuptools
+ import setuptools # noqa
except ImportError:
packages += ["setuptools"]
2  contrib/get-pip.py
View
@@ -20304,7 +20304,7 @@ def bootstrap(tmpdir=None):
# We want to see if setuptools is available before attempting to
# install it
try:
- import setuptools
+ import setuptools # noqa
except ImportError:
packages += ["setuptools"]
25 docs/conf.py
View
@@ -3,7 +3,7 @@
# pip documentation build configuration file, created by
# sphinx-quickstart on Tue Apr 22 22:08:49 2008
#
-# This file is execfile()d with the current directory set to its containing dir.
+# This file is execfile()d with the current directory set to its containing dir
#
# Note that not all possible configuration values are present in this
# autogenerated file.
@@ -22,10 +22,10 @@
sys.path.insert(0, os.path.abspath(os.pardir))
#sys.path.append(os.path.join(os.path.dirname(__file__), '../'))
-# -- General configuration -----------------------------------------------------
+# -- General configuration ----------------------------------------------------
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
#extensions = ['sphinx.ext.autodoc']
extensions = ['docs.pipext']
@@ -76,7 +76,7 @@
# for source files.
exclude_trees = ['build']
-# The reST default role (used for this markup: `text`) to use for all documents.
+# The reST default role (used for this markup: `text`) to use for all documents
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
@@ -96,7 +96,7 @@
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
-# -- Options for HTML output ---------------------------------------------------
+# -- Options for HTML output --------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
@@ -176,7 +176,7 @@
htmlhelp_basename = 'pipdocs'
-# -- Options for LaTeX output --------------------------------------------------
+# -- Options for LaTeX output -------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
@@ -185,10 +185,15 @@
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
+# (source start file, target name, title, author, documentclass [howto/manual])
latex_documents = [
- ('index', 'pip.tex', u'pip Documentation',
- u'The pip developers', 'manual'),
+ (
+ 'index',
+ 'pip.tex',
+ u'pip Documentation',
+ u'The pip developers',
+ 'manual',
+ ),
]
# The name of an image file (relative to this directory) to place at the top of
18 docs/pipext.py
View
@@ -59,7 +59,10 @@ def _format_option(self, option, cmd_name=None):
opt_help = option.help.replace('%default', str(option.default))
#fix paths with sys.prefix
opt_help = opt_help.replace(sys.prefix, "<sys.prefix>")
- opt_help = opt_help.replace(default_log_file, "<see :ref:`FileLogging`>")
+ opt_help = opt_help.replace(
+ default_log_file,
+ "<see :ref:`FileLogging`>",
+ )
return [bookmark_line, "", line, "", " %s" % opt_help, ""]
def _format_options(self, options, cmd_name=None):
@@ -80,12 +83,16 @@ def run(self):
class PipGeneralOptions(PipOptions):
def process_options(self):
- self._format_options([o.make() for o in cmdoptions.general_group['options']])
+ self._format_options(
+ [o.make() for o in cmdoptions.general_group['options']]
+ )
class PipIndexOptions(PipOptions):
def process_options(self):
- self._format_options([o.make() for o in cmdoptions.index_group['options']])
+ self._format_options(
+ [o.make() for o in cmdoptions.index_group['options']]
+ )
class PipCommandOptions(PipOptions):
@@ -93,7 +100,10 @@ class PipCommandOptions(PipOptions):
def process_options(self):
cmd = commands[self.arguments[0]]()
- self._format_options(cmd.parser.option_groups[0].option_list, cmd_name=cmd.name)
+ self._format_options(
+ cmd.parser.option_groups[0].option_list,
+ cmd_name=cmd.name,
+ )
def setup(app):
82 setup.py
View
@@ -25,8 +25,8 @@ def run_tests(self):
def read(*parts):
- # intentionally *not* adding an encoding option to open
- # see here: https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
+ # intentionally *not* adding an encoding option to open, See:
+ # https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
return codecs.open(os.path.join(here, *parts), 'r').read()
@@ -43,40 +43,46 @@ def find_version(*file_paths):
tests_require = ['pytest', 'virtualenv>=1.10', 'scripttest>=1.3', 'mock']
-setup(name="pip",
- version=find_version('pip', '__init__.py'),
- description="A tool for installing and managing Python packages.",
- long_description=long_description,
- classifiers=[
- 'Development Status :: 5 - Production/Stable',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: MIT License',
- 'Topic :: Software Development :: Build Tools',
- 'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.6',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.1',
- 'Programming Language :: Python :: 3.2',
- 'Programming Language :: Python :: 3.3',
- ],
- keywords='easy_install distutils setuptools egg virtualenv',
- author='The pip developers',
- author_email='python-virtualenv@groups.google.com',
- url='http://www.pip-installer.org',
- license='MIT',
- packages=find_packages(exclude=["contrib", "docs", "tests*"]),
- package_data={
- 'pip._vendor.requests': ['*.pem'],
- 'pip._vendor.distlib._backport': ['sysconfig.cfg'],
- 'pip._vendor.distlib': ['t32.exe', 't64.exe', 'w32.exe', 'w64.exe'],
- },
- entry_points=dict(console_scripts=['pip=pip:main', 'pip%s=pip:main' % sys.version[:1],
- 'pip%s=pip:main' % sys.version[:3]]),
- tests_require=tests_require,
- zip_safe=False,
- extras_require={
- 'testing': tests_require,
- },
- cmdclass = {'test': PyTest},
+setup(
+ name="pip",
+ version=find_version("pip", "__init__.py"),
+ description="A tool for installing and managing Python packages.",
+ long_description=long_description,
+ classifiers=[
+ "Development Status :: 5 - Production/Stable",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: MIT License",
+ "Topic :: Software Development :: Build Tools",
+ "Programming Language :: Python :: 2",
+ "Programming Language :: Python :: 2.6",
+ "Programming Language :: Python :: 2.7",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.1",
+ "Programming Language :: Python :: 3.2",
+ "Programming Language :: Python :: 3.3",
+ ],
+ keywords='easy_install distutils setuptools egg virtualenv',
+ author='The pip developers',
+ author_email='python-virtualenv@groups.google.com',
+ url='http://www.pip-installer.org',
+ license='MIT',
+ packages=find_packages(exclude=["contrib", "docs", "tests*"]),
+ package_data={
+ 'pip._vendor.requests': ['*.pem'],
+ 'pip._vendor.distlib._backport': ['sysconfig.cfg'],
+ 'pip._vendor.distlib': ['t32.exe', 't64.exe', 'w32.exe', 'w64.exe'],
+ },
+ entry_points={
+ "console_scripts": [
+ "pip=pip:main",
+ "pip%s=pip:main" % sys.version[:1],
+ "pip%s=pip:main" % sys.version[:3],
+ ],
+ },
+ tests_require=tests_require,
+ zip_safe=False,
+ extras_require={
+ 'testing': tests_require,
+ },
+ cmdclass={'test': PyTest},
)
4 tests/conftest.py
View
@@ -40,7 +40,9 @@ def virtualenv(tmpdir, monkeypatch):
# Copy over our source tree so that each virtual environment is self
# contained
pip_src = tmpdir.join("pip_src").abspath
- shutil.copytree(SRC_DIR, pip_src,
+ shutil.copytree(
+ SRC_DIR,
+ pip_src,
ignore=shutil.ignore_patterns(
"*.pyc", "tests", "pip.egg-info", "build", "dist", ".tox",
),
62 tests/functional/test_bundle.py
View
@@ -1,6 +1,6 @@
import zipfile
import textwrap
-from os.path import abspath, exists, join
+from os.path import exists, join
from pip.download import path_to_url
from tests.lib.local_repos import local_checkout
@@ -14,13 +14,27 @@ def test_create_bundle(script, tmpdir, data):
"""
fspkg = path_to_url(data.packages/'FSPkg')
script.pip('install', '-e', fspkg)
- pkg_lines = textwrap.dedent('''\
+ pkg_lines = textwrap.dedent(
+ '''
-e %s
-e %s#egg=initools-dev
- pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache"))))
+ pip
+ ''' %
+ (
+ fspkg,
+ local_checkout(
+ 'svn+http://svn.colorstudy.com/INITools/trunk',
+ tmpdir.join("cache"),
+ ),
+ ),
+ )
script.scratch_path.join("bundle-req.txt").write(pkg_lines)
# Create a bundle in env.scratch_path/ test.pybundle
- result = script.pip('bundle', '--no-use-wheel', '-r', script.scratch_path/ 'bundle-req.txt', script.scratch_path/ 'test.pybundle')
+ result = script.pip(
+ 'bundle', '--no-use-wheel', '-r',
+ script.scratch_path / 'bundle-req.txt',
+ script.scratch_path / 'test.pybundle',
+ )
bundle = result.files_after.get(join('scratch', 'test.pybundle'), None)
assert bundle is not None
@@ -32,14 +46,20 @@ def test_create_bundle(script, tmpdir, data):
def test_cleanup_after_create_bundle(script, tmpdir, data):
"""
- Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/.
+ Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are
+ removed but not src/.
"""
# Install an editable to create a src/ dir.
args = ['install']
- args.extend(['-e',
- '%s#egg=pip-test-package' %
- local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache"))])
+ args.extend([
+ '-e',
+ '%s#egg=pip-test-package' %
+ local_checkout(
+ 'git+http://github.com/pypa/pip-test-package.git',
+ tmpdir.join("cache"),
+ ),
+ ])
script.pip(*args)
build = script.venv_path/"build"
src = script.venv_path/"src"
@@ -48,16 +68,32 @@ def test_cleanup_after_create_bundle(script, tmpdir, data):
# Make the bundle.
fspkg = path_to_url(data.packages/'FSPkg')
- pkg_lines = textwrap.dedent('''\
+ pkg_lines = textwrap.dedent(
+ '''
-e %s
-e %s#egg=initools-dev
- pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache"))))
+ pip
+ ''' %
+ (
+ fspkg,
+ local_checkout(
+ 'svn+http://svn.colorstudy.com/INITools/trunk',
+ tmpdir.join("cache"),
+ ),
+ ),
+ )
script.scratch_path.join("bundle-req.txt").write(pkg_lines)
- script.pip('bundle', '--no-use-wheel', '-r', 'bundle-req.txt', 'test.pybundle')
+ 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"
- assert not exists(build_bundle), "build-bundle/ dir still exists: %s" % build_bundle
- assert not exists(src_bundle), "src-bundle/ dir still exists: %s" % src_bundle
+ assert not exists(build_bundle), (
+ "build-bundle/ dir still exists: %s" % build_bundle
+ )
+ assert not exists(src_bundle), "src-bundle/ dir still exists: %s" % (
+ src_bundle
+ )
script.assert_no_temp()
# Make sure previously created src/ from editable still exists
6 tests/functional/test_completion.py
View
@@ -62,8 +62,10 @@ def setup_completion(script, words, cword):
script.environ['COMP_CWORD'] = cword
# expect_error is True because autocomplete exists with 1 status code
- result = script.run('python', '-c', 'import pip;pip.autocomplete()',
- expect_error=True)
+ result = script.run(
+ 'python', '-c', 'import pip;pip.autocomplete()',
+ expect_error=True,
+ )
return result, script
236 tests/functional/test_freeze.py
View
@@ -30,7 +30,10 @@ def _check_output(result, expected):
def banner(msg):
return '\n========== %s ==========\n' % msg
- assert checker.check_output(expected, actual, ELLIPSIS), banner('EXPECTED')+expected+banner('ACTUAL')+actual+banner(6*'=')
+ assert checker.check_output(expected, actual, ELLIPSIS), (
+ banner('EXPECTED') + expected + banner('ACTUAL') + actual +
+ banner(6*'=')
+ )
def test_freeze_basic(script):
@@ -47,7 +50,9 @@ def test_freeze_basic(script):
# and something else to test out:
simple2<=3.0
"""))
- result = script.pip_install_local('-r', script.scratch_path/'initools-req.txt')
+ result = script.pip_install_local(
+ '-r', script.scratch_path/'initools-req.txt',
+ )
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
Script result: pip freeze
@@ -61,15 +66,26 @@ def test_freeze_basic(script):
def test_freeze_svn(script, tmpdir):
"""Test freezing a svn checkout"""
- checkout_path = local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache"))
+ checkout_path = local_checkout(
+ 'svn+http://svn.colorstudy.com/INITools/trunk',
+ tmpdir.join("cache"),
+ )
#svn internally stores windows drives as uppercase; we'll match that.
checkout_path = checkout_path.replace('c:', 'C:')
- result = script.run('svn', 'co', '-r10',
- local_repo('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")),
- 'initools-trunk')
- result = script.run('python', 'setup.py', 'develop',
- cwd=script.scratch_path/ 'initools-trunk', expect_stderr=True)
+ result = script.run(
+ 'svn', 'co', '-r10',
+ local_repo(
+ 'svn+http://svn.colorstudy.com/INITools/trunk',
+ tmpdir.join("cache"),
+ ),
+ 'initools-trunk',
+ )
+ result = script.run(
+ 'python', 'setup.py', 'develop',
+ cwd=script.scratch_path / 'initools-trunk',
+ expect_stderr=True,
+ )
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
Script result: ...pip freeze
@@ -82,30 +98,67 @@ def test_freeze_svn(script, tmpdir):
def test_freeze_git_clone(script, tmpdir):
"""
Test freezing a Git clone.
-
"""
- result = script.run('git', 'clone', local_repo('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")), 'pip-test-package', expect_stderr=True)
- result = script.run('git', 'checkout', '7d654e66c8fa7149c165ddeffa5b56bc06619458',
- cwd=script.scratch_path / 'pip-test-package', expect_stderr=True)
- result = script.run('python', 'setup.py', 'develop',
- cwd=script.scratch_path / 'pip-test-package')
+ result = script.run(
+ 'git',
+ 'clone',
+ local_repo(
+ 'git+http://github.com/pypa/pip-test-package.git',
+ tmpdir.join("cache"),
+ ),
+ 'pip-test-package',
+ expect_stderr=True,
+ )
+ result = script.run(
+ 'git',
+ 'checkout',
+ '7d654e66c8fa7149c165ddeffa5b56bc06619458',
+ cwd=script.scratch_path / 'pip-test-package',
+ expect_stderr=True,
+ )
+ result = script.run(
+ 'python', 'setup.py', 'develop',
+ cwd=script.scratch_path / 'pip-test-package'
+ )
result = script.pip('freeze', expect_stderr=True)
- expected = textwrap.dedent("""\
- Script result: ...pip freeze
- -- stdout: --------------------
- ...-e %s@...#egg=pip_test_package-...
- ...""" % local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")))
+ expected = textwrap.dedent(
+ """
+ Script result: ...pip freeze
+ -- stdout: --------------------
+ ...-e %s@...#egg=pip_test_package-...
+ ...
+ """ %
+ local_checkout(
+ 'git+http://github.com/pypa/pip-test-package.git',
+ tmpdir.join("cache"),
+ )
+ ).strip()
_check_output(result, expected)
- result = script.pip('freeze', '-f',
- '%s#egg=pip_test_package' % local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")),
- expect_stderr=True)
- expected = textwrap.dedent("""\
- Script result: pip freeze -f %(repo)s#egg=pip_test_package
- -- stdout: --------------------
- -f %(repo)s#egg=pip_test_package...
- -e %(repo)s@...#egg=pip_test_package-0.1.1
- ...""" % {'repo': local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache"))})
+ result = script.pip(
+ 'freeze', '-f',
+ '%s#egg=pip_test_package' %
+ local_checkout(
+ 'git+http://github.com/pypa/pip-test-package.git',
+ tmpdir.join("cache"),
+ ),
+ expect_stderr=True,
+ )
+ expected = textwrap.dedent(
+ """
+ Script result: pip freeze -f %(repo)s#egg=pip_test_package
+ -- stdout: --------------------
+ -f %(repo)s#egg=pip_test_package...
+ -e %(repo)s@...#egg=pip_test_package-0.1.1
+ ...
+ """ %
+ {
+ 'repo': local_checkout(
+ 'git+http://github.com/pypa/pip-test-package.git',
+ tmpdir.join("cache"),
+ ),
+ },
+ ).strip()
_check_output(result, expected)
@@ -114,29 +167,59 @@ def test_freeze_mercurial_clone(script, tmpdir):
Test freezing a Mercurial clone.
"""
- result = script.run('hg', 'clone',
- '-r', 'c9963c111e7c',
- local_repo('hg+http://bitbucket.org/pypa/pip-test-package', tmpdir.join("cache")),
- 'pip-test-package')
- result = script.run('python', 'setup.py', 'develop',
- cwd=script.scratch_path/'pip-test-package', expect_stderr=True)
+ result = script.run(
+ 'hg', 'clone',
+ '-r', 'c9963c111e7c',
+ local_repo(
+ 'hg+http://bitbucket.org/pypa/pip-test-package',
+ tmpdir.join("cache"),
+ ),
+ 'pip-test-package',
+ )
+ result = script.run(
+ 'python', 'setup.py', 'develop',
+ cwd=script.scratch_path/'pip-test-package',
+ expect_stderr=True,
+ )
result = script.pip('freeze', expect_stderr=True)
- expected = textwrap.dedent("""\
- Script result: ...pip freeze
- -- stdout: --------------------
- ...-e %s@...#egg=pip_test_package-...
- ...""" % local_checkout('hg+http://bitbucket.org/pypa/pip-test-package', tmpdir.join("cache")))
+ expected = textwrap.dedent(
+ """
+ Script result: ...pip freeze
+ -- stdout: --------------------
+ ...-e %s@...#egg=pip_test_package-...
+ ...
+ """ %
+ local_checkout(
+ 'hg+http://bitbucket.org/pypa/pip-test-package',
+ tmpdir.join("cache"),
+ ),
+ ).strip()
_check_output(result, expected)
- result = script.pip('freeze', '-f',
- '%s#egg=pip_test_package' % local_checkout('hg+http://bitbucket.org/pypa/pip-test-package', tmpdir.join("cache")),
- expect_stderr=True)
- expected = textwrap.dedent("""\
- Script result: ...pip freeze -f %(repo)s#egg=pip_test_package
- -- stdout: --------------------
- -f %(repo)s#egg=pip_test_package
- ...-e %(repo)s@...#egg=pip_test_package-dev
- ...""" % {'repo': local_checkout('hg+http://bitbucket.org/pypa/pip-test-package', tmpdir.join("cache"))})
+ result = script.pip(
+ 'freeze', '-f',
+ '%s#egg=pip_test_package' %
+ local_checkout(
+ 'hg+http://bitbucket.org/pypa/pip-test-package',
+ tmpdir.join("cache"),
+ ),
+ expect_stderr=True,
+ )
+ expected = textwrap.dedent(
+ """
+ Script result: ...pip freeze -f %(repo)s#egg=pip_test_package
+ -- stdout: --------------------
+ -f %(repo)s#egg=pip_test_package
+ ...-e %(repo)s@...#egg=pip_test_package-dev
+ ...
+ """ %
+ {
+ 'repo': local_checkout(
+ 'hg+http://bitbucket.org/pypa/pip-test-package',
+ tmpdir.join("cache"),
+ ),
+ },
+ ).strip()
_check_output(result, expected)
@@ -146,15 +229,27 @@ def test_freeze_bazaar_clone(script, tmpdir):
"""
- checkout_path = local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache"))
+ checkout_path = local_checkout(
+ 'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/'
+ 'release-0.1',
+ tmpdir.join("cache"),
+ )
#bzr internally stores windows drives as uppercase; we'll match that.
checkout_pathC = checkout_path.replace('c:', 'C:')
- result = script.run('bzr', 'checkout', '-r', '174',
- local_repo('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache")),
- 'django-wikiapp')
- result = script.run('python', 'setup.py', 'develop',
- cwd=script.scratch_path/'django-wikiapp')
+ result = script.run(
+ 'bzr', 'checkout', '-r', '174',
+ local_repo(
+ 'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/'
+ 'release-0.1',
+ tmpdir.join("cache"),
+ ),
+ 'django-wikiapp',
+ )
+ result = script.run(
+ 'python', 'setup.py', 'develop',
+ cwd=script.scratch_path/'django-wikiapp',
+ )
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
Script result: ...pip freeze
@@ -163,9 +258,11 @@ def test_freeze_bazaar_clone(script, tmpdir):
...""" % checkout_pathC)
_check_output(result, expected)
- result = script.pip('freeze', '-f',
- '%s/#egg=django-wikiapp' % checkout_path,
- expect_stderr=True)
+ result = script.pip(
+ 'freeze', '-f',
+ '%s/#egg=django-wikiapp' % checkout_path,
+ expect_stderr=True,
+ )
expected = textwrap.dedent("""\
Script result: ...pip freeze -f %(repo)s/#egg=django-wikiapp
-- stdout: --------------------
@@ -177,8 +274,8 @@ def test_freeze_bazaar_clone(script, tmpdir):
def test_freeze_with_local_option(script):
"""
- Test that wsgiref (from global site-packages) is reported normally, but not with --local.
-
+ Test that wsgiref (from global site-packages) is reported normally, but not
+ with --local.
"""
result = script.pip('install', 'initools==0.2')
result = script.pip('freeze', expect_stderr=True)
@@ -228,13 +325,16 @@ def test_freeze_with_requirement_option(script):
""") + ignores)
result = script.pip('install', 'initools==0.2')
result = script.pip_install_local('simple')
- result = script.pip('freeze', '--requirement', 'hint.txt', expect_stderr=True)
- expected = textwrap.dedent("""\
- Script result: pip freeze --requirement hint.txt
- -- stderr: --------------------
- Requirement file contains NoExist==4.2, but that package is not installed
-
- -- stdout: --------------------
- INITools==0.2
- """) + ignores + "## The following requirements were added by pip --freeze:..."
+ result = script.pip(
+ 'freeze', '--requirement', 'hint.txt',
+ expect_stderr=True,
+ )
+ expected = """\
+Script result: pip freeze --requirement hint.txt
+-- stderr: --------------------
+Requirement file contains NoExist==4.2, but that package is not installed
+
+-- stdout: --------------------
+INITools==0.2
+""" + ignores + "## The following requirements were added by pip --freeze:..."
_check_output(result, expected)
10 tests/functional/test_help.py
View
@@ -80,6 +80,10 @@ def test_help_commands_equally_functional(script):
assert sum(ret) == 0, 'exit codes of: ' + msg
for name, cls in commands.items():
- if cls.hidden: continue
- assert script.pip('help', name).stdout == \
- script.pip(name, '--help').stdout
+ if cls.hidden:
+ continue
+
+ assert (
+ script.pip('help', name).stdout
+ == script.pip(name, '--help').stdout
+ )
326 tests/functional/test_install.py
View
@@ -1,9 +1,8 @@
import os
-import sys
import textwrap
import glob
-from os.path import abspath, join, curdir, pardir
+from os.path import join, curdir, pardir
import pytest
@@ -22,7 +21,7 @@ def test_without_setuptools(script):
)
assert (
"setuptools must be installed to install from a source distribution"
- in result.stdout
+ in result.stdout
)
@@ -33,7 +32,9 @@ def test_pip_second_command_line_interface_works(script):
args = ['pip%s' % pyversion]
args.extend(['install', 'INITools==0.2'])
result = script.run(*args)
- egg_info_folder = script.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
+ egg_info_folder = (
+ script.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
+ )
initools_folder = script.site_packages / 'initools'
assert egg_info_folder in result.files_created, str(result)
assert initools_folder in result.files_created, str(result)
@@ -44,7 +45,9 @@ def test_install_from_pypi(script):
Test installing a package from PyPI.
"""
result = script.pip('install', '-vvv', 'INITools==0.2')
- egg_info_folder = script.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
+ egg_info_folder = (
+ script.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
+ )
initools_folder = script.site_packages / 'initools'
assert egg_info_folder in result.files_created, str(result)
assert initools_folder in result.files_created, str(result)
@@ -55,7 +58,10 @@ def test_editable_install(script):
Test editable installation.
"""
result = script.pip('install', '-e', 'INITools==0.2', expect_error=True)
- assert "INITools==0.2 should either be a path to a local project or a VCS url" in result.stdout
+ assert (
+ "INITools==0.2 should either be a path to a local project or a VCS url"
+ in result.stdout
+ )
assert len(result.files_created) == 1, result.files_created
assert not result.files_updated, result.files_updated
@@ -64,10 +70,15 @@ def test_install_editable_from_svn(script, tmpdir):
"""
Test checking out from svn.
"""
- result = script.pip('install',
- '-e',
- '%s#egg=initools-dev' %
- local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")))
+ result = script.pip(
+ 'install',
+ '-e',
+ '%s#egg=initools-dev' %
+ local_checkout(
+ 'svn+http://svn.colorstudy.com/INITools/trunk',
+ tmpdir.join("cache")
+ )
+ )
result.assert_installed('INITools', with_files=['.svn'])
@@ -76,82 +87,128 @@ def test_download_editable_to_custom_path(script, tmpdir):
Test downloading an editable using a relative custom src folder.
"""
script.scratch_path.join("customdl").mkdir()
- result = script.pip('install',
- '-e',
- '%s#egg=initools-dev' %
- local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")),
- '--src',
- 'customsrc',
- '--download',
- 'customdl')
+ result = script.pip(
+ 'install',
+ '-e',
+ '%s#egg=initools-dev' %
+ local_checkout(
+ 'svn+http://svn.colorstudy.com/INITools/trunk',
+ tmpdir.join("cache")
+ ),
+ '--src',
+ 'customsrc',
+ '--download',
+ 'customdl',
+ )
customsrc = Path('scratch')/'customsrc'/'initools'
- assert customsrc in result.files_created, sorted(result.files_created.keys())
- assert customsrc/'setup.py' in result.files_created, sorted(result.files_created.keys())
+ assert customsrc in result.files_created, (
+ sorted(result.files_created.keys())
+ )
+ assert customsrc/'setup.py' in result.files_created, (
+ sorted(result.files_created.keys())
+ )
customdl = Path('scratch')/'customdl'/'initools'
- customdl_files_created = [filename for filename in result.files_created
- if filename.startswith(customdl)]
+ customdl_files_created = [
+ filename for filename in result.files_created
+ if filename.startswith(customdl)
+ ]
assert customdl_files_created
def test_editable_no_install_followed_by_no_download(script, tmpdir):
"""
- Test installing an editable in two steps (first with --no-install, then with --no-download).
- """
- result = script.pip('install',
- '-e',
- '%s#egg=initools-dev' %
- local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")),
- '--no-install', expect_error=True)
- result.assert_installed('INITools', without_egg_link=True, with_files=['.svn'])
+ Test installing an editable in two steps (first with --no-install, then
+ with --no-download).
+ """
+ result = script.pip(
+ 'install',
+ '-e',
+ '%s#egg=initools-dev' %
+ local_checkout(
+ 'svn+http://svn.colorstudy.com/INITools/trunk',
+ tmpdir.join("cache"),
+ ),
+ '--no-install',
+ expect_error=True,
+ )
+ result.assert_installed(
+ 'INITools', without_egg_link=True, with_files=['.svn'],
+ )
- result = script.pip('install',
- '-e',
- '%s#egg=initools-dev' %
- local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")),
- '--no-download', expect_error=True)
+ result = script.pip(
+ 'install',
+ '-e',
+ '%s#egg=initools-dev' %
+ local_checkout(
+ 'svn+http://svn.colorstudy.com/INITools/trunk',
+ tmpdir.join("cache"),
+ ),
+ '--no-download',
+ expect_error=True,
+ )
result.assert_installed('INITools', without_files=[curdir, '.svn'])
def test_no_install_followed_by_no_download(script):
"""
- Test installing in two steps (first with --no-install, then with --no-download).
+ Test installing in two steps (first with --no-install, then with
+ --no-download).
"""
- egg_info_folder = script.site_packages/'INITools-0.2-py%s.egg-info' % pyversion
+ egg_info_folder = (
+ script.site_packages/'INITools-0.2-py%s.egg-info' % pyversion
+ )
initools_folder = script.site_packages/'initools'
build_dir = script.venv/'build'/'INITools'
- result1 = script.pip('install', 'INITools==0.2', '--no-install', expect_error=True)
+ result1 = script.pip(
+ 'install', 'INITools==0.2', '--no-install', expect_error=True,
+ )
assert egg_info_folder not in result1.files_created, str(result1)
- assert initools_folder not in result1.files_created, sorted(result1.files_created)
+ assert initools_folder not in result1.files_created, (
+ sorted(result1.files_created)
+ )
assert build_dir in result1.files_created, 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)
+ result2 = script.pip(
+ 'install', 'INITools==0.2', '--no-download', expect_error=True,
+ )
assert egg_info_folder in result2.files_created, str(result2)
- assert initools_folder in result2.files_created, sorted(result2.files_created)
+ assert initools_folder in result2.files_created, (
+ sorted(result2.files_created)
+ )
assert build_dir not in result2.files_created
assert build_dir/'INITools.egg-info' not in result2.files_created
def test_bad_install_with_no_download(script):
"""
- Test that --no-download behaves sensibly if the package source can't be found.
+ Test that --no-download behaves sensibly if the package source can't be
+ found.
"""
- result = script.pip('install', 'INITools==0.2', '--no-download', expect_error=True)
- assert "perhaps --no-download was used without first running "\
- "an equivalent install with --no-install?" in result.stdout
+ result = script.pip(
+ 'install', 'INITools==0.2', '--no-download', expect_error=True,
+ )
+ assert (
+ "perhaps --no-download was used without first running "
+ "an equivalent install with --no-install?" in result.stdout
+ )
def test_install_dev_version_from_pypi(script):
"""
Test using package==dev.
"""
- result = script.pip('install', 'INITools==dev',
- '--allow-external', 'INITools',
- '--allow-unverified', 'INITools',
- expect_error=True)
- assert (script.site_packages / 'initools') in result.files_created, str(result.stdout)
+ result = script.pip(
+ 'install', 'INITools==dev',
+ '--allow-external', 'INITools',
+ '--allow-unverified', 'INITools',
+ expect_error=True,
+ )
+ assert (script.site_packages / 'initools') in result.files_created, (
+ str(result.stdout)
+ )
def test_install_editable_from_git(script, tmpdir):
@@ -159,9 +216,14 @@ def test_install_editable_from_git(script, tmpdir):
Test cloning from Git.
"""
args = ['install']
- args.extend(['-e',
- '%s#egg=pip-test-package' %
- local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache"))])
+ args.extend([
+ '-e',
+ '%s#egg=pip-test-package' %
+ local_checkout(
+ 'git+http://github.com/pypa/pip-test-package.git',
+ tmpdir.join("cache"),
+ ),
+ ])
result = script.pip(*args, **{"expect_error": True})
result.assert_installed('pip-test-package', with_files=['.git'])
@@ -170,10 +232,15 @@ def test_install_editable_from_hg(script, tmpdir):
"""
Test cloning from Mercurial.
"""
- result = script.pip('install', '-e',
- '%s#egg=ScriptTest' %
- local_checkout('hg+https://bitbucket.org/ianb/scripttest', tmpdir.join("cache")),
- expect_error=True)
+ result = script.pip(
+ 'install', '-e',
+ '%s#egg=ScriptTest' %
+ local_checkout(
+ 'hg+https://bitbucket.org/ianb/scripttest',
+ tmpdir.join("cache"),
+ ),
+ expect_error=True,
+ )
result.assert_installed('ScriptTest', with_files=['.hg'])
@@ -181,21 +248,34 @@ def test_vcs_url_final_slash_normalization(script, tmpdir):
"""
Test that presence or absence of final slash in VCS URL is normalized.
"""
- result = script.pip('install', '-e',
- '%s/#egg=ScriptTest' %
- local_checkout('hg+https://bitbucket.org/ianb/scripttest', tmpdir.join("cache")),
- expect_error=True)
- assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
+ result = script.pip(
+ 'install', '-e',
+ '%s/#egg=ScriptTest' %
+ local_checkout(
+ 'hg+https://bitbucket.org/ianb/scripttest',
+ tmpdir.join("cache"),
+ ),
+ expect_error=True,
+ )
+ assert 'pip-log.txt' not in result.files_created, (
+ result.files_created['pip-log.txt'].bytes
+ )
def test_install_editable_from_bazaar(script, tmpdir):
"""
Test checking out from Bazaar.
"""
- result = script.pip('install', '-e',
- '%s/@174#egg=django-wikiapp' %
- local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache")),
- expect_error=True)
+ result = script.pip(
+ 'install', '-e',
+ '%s/@174#egg=django-wikiapp' %
+ local_checkout(
+ 'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp'
+ '/release-0.1',
+ tmpdir.join("cache"),
+ ),
+ expect_error=True,
+ )
result.assert_installed('django-wikiapp', with_files=['.bzr'])
@@ -203,11 +283,19 @@ def test_vcs_url_urlquote_normalization(script, tmpdir):
"""
Test that urlquoted characters are normalized for repo URL comparison.
"""
- result = script.pip('install', '-e',
- '%s/#egg=django-wikiapp' %
- local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache")),
- expect_error=True)
- assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
+ result = script.pip(
+ 'install', '-e',
+ '%s/#egg=django-wikiapp' %
+ local_checkout(
+ 'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp'
+ '/release-0.1',
+ tmpdir.join("cache"),
+ ),
+ expect_error=True,
+ )
+ assert 'pip-log.txt' not in result.files_created, (
+ result.files_created['pip-log.txt'].bytes
+ )
def test_install_from_local_directory(script, data):
@@ -217,19 +305,24 @@ 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'
- egg_info_folder = script.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion
+ egg_info_folder = (
+ 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)
-def test_install_from_local_directory_with_symlinks_to_directories(script, data):
+def test_install_from_local_directory_with_symlinks_to_directories(
+ script, data):
"""
Test installing from a local directory containing symlinks to directories.
"""
to_install = data.packages.join("symlinks")
result = script.pip('install', to_install, expect_error=False)
pkg_folder = script.site_packages/'symlinks'
- egg_info_folder = script.site_packages/'symlinks-0.1dev-py%s.egg-info' % pyversion
+ egg_info_folder = (
+ 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)
@@ -278,7 +371,9 @@ def test_install_curdir(script, data):
rmtree(egg_info)
result = script.pip('install', curdir, cwd=run_from, expect_error=False)
fspkg_folder = script.site_packages/'fspkg'
- egg_info_folder = script.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion
+ egg_info_folder = (
+ 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)
@@ -290,7 +385,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'
- egg_info_folder = script.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion
+ egg_info_folder = (
+ 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)
@@ -300,7 +397,9 @@ def test_install_global_option(script):
Test using global distutils options.
(In particular those that disable the actual install action)
"""
- result = script.pip('install', '--global-option=--version', "INITools==0.1")
+ result = script.pip(
+ 'install', '--global-option=--version', "INITools==0.1",
+ )
assert '0.1\n' in result.stdout
@@ -327,10 +426,14 @@ def test_install_using_install_option_and_editable(script, tmpdir):
folder = 'script_folder'
script.scratch_path.join(folder).mkdir()
url = 'git+git://github.com/pypa/virtualenv'
- result = script.pip('install', '-e', '%s#egg=virtualenv' %
- local_checkout(url, tmpdir.join("cache")),
- '--install-option=--script-dir=%s' % folder)
- virtualenv_bin = script.venv/'src'/'virtualenv'/folder/'virtualenv'+script.exe
+ result = script.pip(
+ 'install', '-e', '%s#egg=virtualenv' %
+ local_checkout(url, tmpdir.join("cache")),
+ '--install-option=--script-dir=%s' % folder
+ )
+ virtualenv_bin = (
+ script.venv/'src'/'virtualenv'/folder/'virtualenv'+script.exe
+ )
assert virtualenv_bin in result.files_created
@@ -339,9 +442,10 @@ def test_install_global_option_using_editable(script, tmpdir):
Test using global distutils options, but in an editable installation
"""
url = 'hg+http://bitbucket.org/runeh/anyjson'
- result = script.pip('install', '--global-option=--version',
- '-e', '%s@0.2.5#egg=anyjson' %
- local_checkout(url, tmpdir.join("cache")))
+ result = script.pip(
+ 'install', '--global-option=--version', '-e',
+ '%s@0.2.5#egg=anyjson' % local_checkout(url, tmpdir.join("cache"))
+ )
assert '0.2.5\n' in result.stdout
@@ -404,7 +508,9 @@ def test_install_package_which_contains_dev_in_name(script):
"""
result = script.pip('install', 'django-devserver==0.0.4')
devserver_folder = script.site_packages/'devserver'
- egg_info_folder = script.site_packages/'django_devserver-0.0.4-py%s.egg-info' % pyversion
+ egg_info_folder = (
+ 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)
@@ -415,7 +521,9 @@ def test_install_package_with_target(script):
"""
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, str(result)
+ assert Path('scratch')/'target'/'initools' in result.files_created, (
+ str(result)
+ )
def test_install_package_with_root(script, data):
@@ -423,11 +531,20 @@ def test_install_package_with_root(script, data):
Test installing a package using pip install --root
"""
root_dir = script.scratch_path/'root'
- result = script.pip('install', '--root', root_dir, '-f', data.find_links, '--no-index', 'simple==1.0')
- normal_install_path = script.base_path / script.site_packages / 'simple-1.0-py%s.egg-info' % pyversion
- #use distutils to change the root exactly how the --root option does it
+ result = script.pip(
+ 'install', '--root', root_dir, '-f', data.find_links, '--no-index',
+ 'simple==1.0',
+ )
+ normal_install_path = (
+ script.base_path / script.site_packages / 'simple-1.0-py%s.egg-info' %
+ pyversion
+ )
+ # use distutils to change the root exactly how the --root option does it
from distutils.util import change_root
- root_path = change_root(os.path.join(script.scratch, 'root'), normal_install_path)
+ root_path = change_root(
+ os.path.join(script.scratch, 'root'),
+ normal_install_path
+ )
assert root_path in result.files_created, str(result)
@@ -436,43 +553,44 @@ def test_install_package_with_root(script, data):
def test_install_package_that_emits_unicode(script, data):
"""
Install a package with a setup.py that emits UTF-8 output and then fails.
- This works fine in Python 2, but fails in Python 3 with:
-
- Traceback (most recent call last):
- ...
- File "/Users/marc/python/virtualenvs/py3.1-phpserialize/lib/python3.2/site-packages/pip-1.0.2-py3.2.egg/pip/__init__.py", line 230, in call_subprocess
- line = console_to_str(stdout.readline())
- File "/Users/marc/python/virtualenvs/py3.1-phpserialize/lib/python3.2/site-packages/pip-1.0.2-py3.2.egg/pip/backwardcompat.py", line 60, in console_to_str
- return s.decode(console_encoding)
- UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 17: ordinal not in range(128)
Refs https://github.com/pypa/pip/issues/326
"""
to_install = data.packages.join("BrokenEmitsUTF8")
- result = script.pip('install', to_install, expect_error=True, expect_temp=True, quiet=True)
- assert 'FakeError: this package designed to fail on install' in result.stdout
+ result = script.pip(
+ 'install', to_install, expect_error=True, expect_temp=True, quiet=True,
+ )
+ assert (
+ 'FakeError: this package designed to fail on install' in result.stdout
+ )
assert 'UnicodeDecodeError' not in result.stdout
+
def test_install_package_with_utf8_setup(script, data):
"""Install a package with a setup.py that declares a utf-8 encoding."""
to_install = data.packages.join("SetupPyUTF8")
script.pip('install', to_install)
+
def test_install_package_with_latin1_setup(script, data):
"""Install a package with a setup.py that declares a latin-1 encoding."""
to_install = data.packages.join("SetupPyLatin1")
script.pip('install', to_install)
+
def test_url_req_case_mismatch(script, data):
"""
- tar ball url requirements (with no egg fragment), that happen to have upper case project names,
- should be considered equal to later requirements that reference the project name using lower case.
+ tar ball url requirements (with no egg fragment), that happen to have upper
+ case project names, should be considered equal to later requirements that
+ reference the project name using lower case.
tests/packages contains Upper-1.0.tar.gz and Upper-2.0.tar.gz
'requiresupper' has install_requires = ['upper']
"""
Upper = os.path.join(data.find_links, 'Upper-1.0.tar.gz')
- result = script.pip('install', '--no-index', '-f', data.find_links, Upper, 'requiresupper')
+ result = script.pip(
+ 'install', '--no-index', '-f', data.find_links, Upper, 'requiresupper'
+ )
#only Upper-1.0.tar.gz should get installed.
egg_folder = script.site_packages / 'Upper-1.0-py%s.egg-info' % pyversion
71 tests/functional/test_install_cleanup.py
View
@@ -1,6 +1,6 @@
import os
-from os.path import abspath, exists, join
+from os.path import exists
from tests.lib.local_repos import local_checkout
from tests.lib.path import Path
@@ -12,7 +12,9 @@ def test_cleanup_after_install(script, data):
"""
Test clean up after installing a package.
"""
- script.pip('install', '--no-index', '--find-links=%s' % data.find_links, 'simple')
+ script.pip(
+ 'install', '--no-index', '--find-links=%s' % data.find_links, 'simple'
+ )
build = script.venv_path/"build"
src = script.venv_path/"src"
assert not exists(build), "build/ dir still exists: %s" % build
@@ -24,7 +26,10 @@ def test_no_clean_option_blocks_cleaning_after_install(script, data):
"""
Test --no-clean option blocks cleaning after install
"""
- result = script.pip('install', '--no-clean', '--no-index', '--find-links=%s' % data.find_links, 'simple')
+ result = script.pip(
+ 'install', '--no-clean', '--no-index',
+ '--find-links=%s' % data.find_links, 'simple'
+ )
build = script.venv_path/'build'/'simple'
assert exists(build), "build/simple should still exist %s" % str(result)
@@ -34,11 +39,16 @@ def test_cleanup_after_install_editable_from_hg(script, tmpdir):
Test clean up after cloning from Mercurial.
"""
- script.pip('install',
- '-e',
- '%s#egg=ScriptTest' %
- local_checkout('hg+https://bitbucket.org/ianb/scripttest', tmpdir.join("cache")),
- expect_error=True)
+ script.pip(
+ 'install',
+ '-e',
+ '%s#egg=ScriptTest' %
+ local_checkout(
+ 'hg+https://bitbucket.org/ianb/scripttest',
+ tmpdir.join("cache"),
+ ),
+ expect_error=True,
+ )
build = script.venv_path/'build'
src = script.venv_path/'src'
assert not exists(build), "build/ dir still exists: %s" % build
@@ -65,9 +75,16 @@ def test_no_install_and_download_should_not_leave_build_dir(script):
"""
script.scratch_path.join("downloaded_packages").mkdir()
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' not in result.files_created, 'pip should not leave build/ dir'
- assert not os.path.exists(script.venv_path/'/build'), "build/ dir should be deleted"
+ result = script.pip(
+ 'install', '--no-install', 'INITools==0.2', '-d', 'downloaded_packages'
+ )
+ assert (
+ Path('scratch')/'downloaded_packages/build'
+ not in result.files_created
+ ), 'pip should not leave build/ dir'
+ assert not os.path.exists(script.venv_path/'/build'), (
+ "build/ dir should be deleted"
+ )
def test_cleanup_req_satisifed_no_name(script, data):
@@ -75,13 +92,16 @@ def test_cleanup_req_satisifed_no_name(script, data):
Test cleanup when req is already satisfied, and req has no 'name'
"""
#this test confirms Issue #420 is fixed
- #reqs with no 'name' that were already satisfied were leaving behind tmp build dirs
+ #reqs with no 'name' that were already satisfied were leaving behind tmp
+ # build dirs
#2 examples of reqs that would do this
# 1) https://bitbucket.org/ianb/initools/get/tip.zip
# 2) parent-0.1.tar.gz
dist = data.packages.join("parent-0.1.tar.gz")
- result = script.pip('install', dist)
- result = script.pip('install', dist)
+
+ script.pip('install', dist)
+ script.pip('install', dist)
+
build = script.venv_path/'build'
assert not exists(build), "unexpected build/ dir exists: %s" % build
script.assert_no_temp()
@@ -96,8 +116,12 @@ def test_download_should_not_delete_existing_build_dir(script):
script.pip('install', '--no-install', 'INITools==0.2', '-d', '.')
with open(script.venv_path/'build'/'somefile.txt') as fp:
content = fp.read()
- 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 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')
@@ -106,7 +130,10 @@ def test_cleanup_after_install_exception(script, data):
Test clean up after a 'setup.py install' exception.
"""
#broken==0.2broken fails during install; see packages readme file
- result = script.pip('install', '-f', data.find_links, '--no-index', 'broken==0.2broken', expect_error=True)
+ result = script.pip(
+ 'install', '-f', data.find_links, '--no-index', 'broken==0.2broken',
+ expect_error=True,
+ )
build = script.venv_path/'build'
assert not exists(build), "build/ dir still exists: %s" % result.stdout
script.assert_no_temp()
@@ -117,7 +144,10 @@ def test_cleanup_after_egg_info_exception(script, data):
Test clean up after a 'setup.py egg_info' exception.
"""
#brokenegginfo fails during egg_info; see packages readme file
- result = script.pip('install', '-f', data.find_links, '--no-index', 'brokenegginfo==0.1', expect_error=True)
+ result = script.pip(
+ 'install', '-f', data.find_links, '--no-index', 'brokenegginfo==0.1',
+ expect_error=True,
+ )
build = script.venv_path/'build'
assert not exists(build), "build/ dir still exists: %s" % result.stdout
script.assert_no_temp()
@@ -131,7 +161,10 @@ def test_cleanup_prevented_upon_build_dir_exception(script, data):
os.makedirs(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', expect_error=True)
+ result = script.pip(
+ 'install', '-f', data.find_links, '--no-index', 'simple',
+ expect_error=True,
+ )
assert result.returncode == PREVIOUS_BUILD_DIR_ERROR
assert "pip can't proceed" in result.stdout, result.stdout
5 tests/functional/test_install_compat.py
View
@@ -23,8 +23,9 @@ def test_debian_egg_name_workaround(script):
script.site_packages, "INITools-0.2-py%s.egg-info" % pyversion)
# Debian only removes pyversion for global installs, not inside a venv
- # so even if this test runs on a Debian/Ubuntu system with broken setuptools,
- # since our test runs inside a venv we'll still have the normal .egg-info
+ # so even if this test runs on a Debian/Ubuntu system with broken
+ # setuptools, since our test runs inside a venv we'll still have the normal
+ # .egg-info
assert egg_info in result.files_created, "Couldn't find %s" % egg_info
# The Debian no-pyversion version of the .egg-info
77 tests/functional/test_install_config.py
View
@@ -11,7 +11,10 @@ def test_options_from_env_vars(script):
script.environ['PIP_NO_INDEX'] = '1'
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
assert "Ignoring indexes:" in result.stdout, str(result)
- assert "DistributionNotFound: No distributions at all found for INITools" in result.stdout
+ assert (
+ "DistributionNotFound: No distributions at all found for INITools"
+ in result.stdout
+ )
def test_command_line_options_override_env_vars(script, virtualenv):
@@ -21,9 +24,16 @@ def test_command_line_options_override_env_vars(script, virtualenv):
"""
script.environ['PIP_INDEX_URL'] = 'http://b.pypi.python.org/simple/'
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
- assert "Getting page http://b.pypi.python.org/simple/INITools" in result.stdout
+ assert (
+ "Getting page http://b.pypi.python.org/simple/INITools"
+ in result.stdout
+ )
virtualenv.clear()
- result = script.pip('install', '-vvv', '--index-url', 'http://download.zope.org/ppix', 'INITools', expect_error=True)
+ result = script.pip(
+ 'install', '-vvv', '--index-url', 'http://download.zope.org/ppix',
+ 'INITools',
+ expect_error=True,
+ )
assert "b.pypi.python.org" not in result.stdout
assert "Getting page http://download.zope.org/ppix" in result.stdout
@@ -55,7 +65,10 @@ def _test_env_vars_override_config_file(script, virtualenv, config_file):
no-index = 1
"""))
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
- assert "DistributionNotFound: No distributions at all found for INITools" in result.stdout
+ assert (
+ "DistributionNotFound: No distributions at all found for INITools"
+ in result.stdout
+ )
script.environ['PIP_NO_INDEX'] = '0'
virtualenv.clear()
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
@@ -64,15 +77,25 @@ def _test_env_vars_override_config_file(script, virtualenv, config_file):
def test_command_line_append_flags(script, virtualenv, data):
"""
- Test command line flags that append to defaults set by environmental variables.
+ Test command line flags that append to defaults set by environmental
+ variables.
"""
script.environ['PIP_FIND_LINKS'] = 'http://pypi.pinaxproject.com'
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
- assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
+ assert (
+ "Analyzing links from page http://pypi.pinaxproject.com"
+ in result.stdout
+ )
virtualenv.clear()
- result = script.pip('install', '-vvv', '--find-links', data.find_links, 'INITools', expect_error=True)
- assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
+ result = script.pip(
+ 'install', '-vvv', '--find-links', data.find_links, 'INITools',
+ expect_error=True,
+ )
+ assert (
+ "Analyzing links from page http://pypi.pinaxproject.com"
+ in result.stdout
+ )
assert "Skipping link %s" % data.find_links in result.stdout
@@ -81,10 +104,15 @@ def test_command_line_appends_correctly(script, data):
Test multiple appending options set by environmental variables.
"""
- script.environ['PIP_FIND_LINKS'] = 'http://pypi.pinaxproject.com %s' % data.find_links
+ script.environ['PIP_FIND_LINKS'] = (
+ 'http://pypi.pinaxproject.com %s' % data.find_links
+ )
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
- assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout, result.stdout
+ assert (
+ "Analyzing links from page http://pypi.pinaxproject.com"
+ in result.stdout
+ ), result.stdout
assert "Skipping link %s" % data.find_links in result.stdout
@@ -105,13 +133,16 @@ def test_config_file_override_stack(script, virtualenv):
def _test_config_file_override_stack(script, virtualenv, config_file):
- script.environ['PIP_CONFIG_FILE'] = config_file # set this to make pip load it
+ # set this to make pip load it
+ script.environ['PIP_CONFIG_FILE'] = config_file
(script.scratch_path/config_file).write(textwrap.dedent("""\
[global]
index-url = http://download.zope.org/ppix
"""))
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
- assert "Getting page http://download.zope.org/ppix/INITools" in result.stdout
+ assert (
+ "Getting page http://download.zope.org/ppix/INITools" in result.stdout
+ )
virtualenv.clear()
(script.scratch_path/config_file).write(textwrap.dedent("""\
[global]
@@ -121,10 +152,19 @@ def _test_config_file_override_stack(script, virtualenv, config_file):
"""))
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
- result = script.pip('install', '-vvv', '--index-url', 'http://pypi.python.org/simple', 'INITools', expect_error=True)
- assert "Getting page http://download.zope.org/ppix/INITools" not in result.stdout
+ result = script.pip(
+ 'install', '-vvv', '--index-url', 'http://pypi.python.org/simple',
+ 'INITools',
+ expect_error=True,
+ )
+ assert (
+ "Getting page http://download.zope.org/ppix/INITools"
+ not in result.stdout
+ )
assert "Getting page http://pypi.appspot.com/INITools" not in result.stdout
- assert "Getting page http://pypi.python.org/simple/INITools" in result.stdout
+ assert (
+ "Getting page http://pypi.python.org/simple/INITools" in result.stdout
+ )
def test_log_file_no_directory():
@@ -152,6 +192,7 @@ def test_options_from_venv_config(script, virtualenv):
f.write(conf)
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
assert "Ignoring indexes:" in result.stdout, str(result)
- assert "DistributionNotFound: No distributions at all found for INITools" in result.stdout
-
-
+ assert (
+ "DistributionNotFound: No distributions at all found for INITools"
+ in result.stdout
+ )
75 tests/functional/test_install_download.py
View
@@ -7,9 +7,11 @@ def test_download_if_requested(script):
"""
It should download (in the scratch path) and not install if requested.
"""
- result = script.pip('install', 'INITools==0.1', '-d', '.', expect_error=True)
- assert Path('scratch')/ 'INITools-0.1.tar.gz' in result.files_created
- assert script.site_packages/ 'initools' not in result.files_created
+ result = script.pip(
+ 'install', 'INITools==0.1', '-d', '.', expect_error=True
+ )
+ assert Path('scratch') / 'INITools-0.1.tar.gz' in result.files_created
+ assert script.site_packages / 'initools' not in result.files_created
def test_download_wheel(script):
@@ -18,34 +20,47 @@ def test_download_wheel(script):
FIXME: this test could use a local --find-links dir, but -d with local
--find-links has a bug https://github.com/pypa/pip/issues/1111
"""
- result = script.pip('install', '--use-wheel',
- '-f', 'https://bitbucket.org/pypa/pip-test-package/downloads',
- '-d', '.', 'pip-test-package')
- assert Path('scratch')/ 'pip_test_package-0.1.1-py2.py3-none-any.whl' in result.files_created
- assert script.site_packages/ 'piptestpackage' not in result.files_created
+ result = script.pip(
+ 'install', '--use-wheel',
+ '-f', 'https://bitbucket.org/pypa/pip-test-package/downloads',
+ '-d', '.', 'pip-test-package'
+ )
+ assert (
+ Path('scratch') / 'pip_test_package-0.1.1-py2.py3-none-any.whl'
+ in result.files_created
+ )
+ assert script.site_packages / 'piptestpackage' not in result.files_created
def test_single_download_from_requirements_file(script):
"""
- It should support download (in the scratch path) from PyPi from a requirements file
+ It should support download (in the scratch path) from PyPi from a
+ requirements file
"""
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
INITools==0.1
"""))
- result = script.pip('install', '-r', script.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True)
- assert Path('scratch')/ 'INITools-0.1.tar.gz' in result.files_created
- assert script.site_packages/ 'initools' not in result.files_created
+ result = script.pip(
+ 'install', '-r', script.scratch_path / 'test-req.txt', '-d', '.',
+ expect_error=True,
+ )
+ assert Path('scratch') / 'INITools-0.1.tar.gz' in result.files_created
+ assert script.site_packages / 'initools' not in result.files_created
def test_download_should_download_dependencies(script):
"""
It should download dependencies (in the scratch path)
"""
- result = script.pip('install', 'Paste[openid]==1.7.5.1', '-d', '.', expect_error=True)
- assert Path('scratch')/ 'Paste-1.7.5.1.tar.gz' in result.files_created
- openid_tarball_prefix = str(Path('scratch')/ 'python-openid-')
- assert any(path.startswith(openid_tarball_prefix) for path in result.files_created)
- assert script.site_packages/ 'openid' not in result.files_created
+ result = script.pip(
+ 'install', 'Paste[openid]==1.7.5.1', '-d', '.', expect_error=True,
+ )
+ assert Path('scratch') / 'Paste-1.7.5.1.tar.gz' in result.files_created
+ openid_tarball_prefix = str(Path('scratch') / 'python-openid-')
+ assert any(
+ path.startswith(openid_tarball_prefix) for path in result.files_created
+ )
+ assert script.site_packages / 'openid' not in result.files_created
def test_download_should_skip_existing_files(script):
@@ -56,9 +71,12 @@ def test_download_should_skip_existing_files(script):
INITools==0.1
"""))
- result = script.pip('install', '-r', script.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True)
- assert Path('scratch')/ 'INITools-0.1.tar.gz' in result.files_created
- assert script.site_packages/ 'initools' not in result.files_created
+ result = script.pip(
+ 'install', '-r', script.scratch_path / 'test-req.txt', '-d', '.',
+ expect_error=True,
+ )
+ assert Path('scratch') / 'INITools-0.1.tar.gz' in result.files_created
+ assert script.site_packages / 'initools' not in result.files_created
# adding second package to test-req.txt
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
@@ -67,9 +85,14 @@ def test_download_should_skip_existing_files(script):
"""))
# only the second package should be downloaded
- result = script.pip('install', '-r', script.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True)
- openid_tarball_prefix = str(Path('scratch')/ 'python-openid-')
- assert any(path.startswith(openid_tarball_prefix) for path in result.files_created)
- assert Path('scratch')/ 'INITools-0.1.tar.gz' not in result.files_created
- assert script.site_packages/ 'initools' not in result.files_created
- assert script.site_packages/ 'openid' not in result.files_created
+ result = script.pip(
+ 'install', '-r', script.scratch_path / 'test-req.txt', '-d', '.',
+ expect_error=True,
+ )
+ openid_tarball_prefix = str(Path('scratch') / 'python-openid-')
+ assert any(
+ path.startswith(openid_tarball_prefix) for path in result.files_created
+ )
+ assert Path('scratch') / 'INITools-0.1.tar.gz' not in result.files_created
+ assert script.site_packages / 'initools' not in result.files_created
+ assert script.site_packages / 'openid' not in result.files_created
16 tests/functional/test_install_extras.py
View
@@ -5,7 +5,9 @@ def test_simple_extras_install_from_pypi(script):
"""
Test installing a package from PyPI using extras dependency Paste[openid].
"""
- result = script.pip('install', 'Paste[openid]==1.7.5.1', expect_stderr=True)
+ result = script.pip(
+ 'install', 'Paste[openid]==1.7.5.1', expect_stderr=True,
+ )
initools_folder = script.site_packages / 'openid'
assert initools_folder in result.files_created, result.files_created
@@ -14,9 +16,15 @@ def test_no_extras_uninstall(script):
"""
No extras dependency gets uninstalled when the root package is uninstalled
"""
- result = script.pip('install', 'Paste[openid]==1.7.5.1', expect_stderr=True)
- assert join(script.site_packages, 'paste') in result.files_created, sorted(result.files_created.keys())
- assert join(script.site_packages, 'openid') in result.files_created, sorted(result.files_created.keys())
+ result = script.pip(
+ 'install', 'Paste[openid]==1.7.5.1', expect_stderr=True,
+ )
+ assert join(script.site_packages, 'paste') in result.files_created, (
+ sorted(result.files_created.keys())
+ )
+ assert join(script.site_packages, 'openid') in result.files_created, (
+ sorted(result.files_created.keys())
+ )
result2 = script.pip('uninstall', 'Paste', '-y')
# openid should not be uninstalled
initools_folder = script.site_packages / 'openid'
31 tests/functional/test_install_index.py
View
@@ -1,9 +1,8 @@
-import os
import textwrap
from pip.backwardcompat import urllib
-from tests.lib import pyversion, path_to_url
+from tests.lib import pyversion
def test_find_links_relative_path(script, data):
@@ -16,7 +15,9 @@ def test_find_links_relative_path(script, data):
'packages/',
cwd=data.root,
)
- egg_info_folder = script.site_packages / 'parent-0.1-py%s.egg-info' % pyversion
+ egg_info_folder = (
+ script.site_packages / 'parent-0.1-py%s.egg-info' % pyversion
+ )
initools_folder = script.site_packages / 'parent'
assert egg_info_folder in result.files_created, str(result)
assert initools_folder in result.files_created, str(result)
@@ -35,7 +36,9 @@ def test_find_links_requirements_file_relative_path(script, data):
script.scratch_path / "test-req.txt",
cwd=data.root,
)
- egg_info_folder = script.site_packages / 'parent-0.1-py%s.egg-info' % pyversion
+ egg_info_folder = (
+ script.site_packages / 'parent-0.1-py%s.egg-info' % pyversion
+ )
initools_folder = script.site_packages / 'parent'
assert egg_info_folder in result.files_created, str(result)
assert initools_folder in result.files_created, str(result)
@@ -43,10 +46,13 @@ def test_find_links_requirements_file_relative_path(script, data):
def test_install_from_file_index_hash_link(script, data):
"""
- Test that a pkg can be installed from a file:// index using a link with a hash
+ Test that a pkg can be installed from a file:// index using a link with a
+ hash
"""
result = script.pip('install', '-i', data.index_url(), 'simple==1.0')
- egg_info_folder = script.site_packages / 'simple-1.0-py%s.egg-info' % pyversion
+ egg_info_folder = (
+ script.site_packages / 'simple-1.0-py%s.egg-info' % pyversion
+ )
assert egg_info_folder in result.files_created, str(result)
@@ -55,6 +61,13 @@ def test_file_index_url_quoting(script, data):
Test url quoting of file index url with a space
"""
index_url = data.index_url(urllib.quote("in dex"))
- result = script.pip('install', '-vvv', '--index-url', index_url, 'simple', expect_error=False)
- assert (script.site_packages/'simple') in result.files_created, str(result.stdout)
- assert (script.site_packages/'simple-1.0-py%s.egg-info' % pyversion) in result.files_created, str(result)
+ result = script.pip(
+ 'install', '-vvv', '--index-url', index_url, 'simple',
+ expect_error=False,
+ )
+ assert (script.site_packages/'simple') in result.files_created, (
+ str(result.stdout)
+ )
+ assert (
+ script.site_packages/'simple-1.0-py%s.egg-info' % pyversion
+ ) in result.files_created, str(result)
112 tests/functional/test_install_reqs.py
View
@@ -3,15 +3,9 @@
import pytest
-from mock import patch
-
-from pip.backwardcompat import urllib
-from pip.req import Requirements, parse_requirements
-from pip.req.req_install import parse_editable
from tests.lib import (pyversion, path_to_url,
_create_test_package_with_subdirectory)
from tests.lib.local_repos import local_checkout
-from tests.lib.path import Path
def test_requirements_file(script):
@@ -25,8 +19,13 @@ def test_requirements_file(script):
# and something else to test out:
%s<=%s
""" % (other_lib_name, other_lib_version)))
- result = script.pip('install', '-r', script.scratch_path / 'initools-req.txt')
- assert script.site_packages/'INITools-0.2-py%s.egg-info' % pyversion in result.files_created
+ result = script.pip(
+ 'install', '-r', script.scratch_path / 'initools-req.txt'
+ )
+ assert (
+ 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
fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion)
@@ -38,26 +37,40 @@ def test_schema_check_in_requirements_file(script):
Test installing from a requirements file with an invalid vcs schema..
"""
- script.scratch_path.join("file-egg-req.txt").write(textwrap.dedent("""\
- git://github.com/alex/django-fixture-generator.git#egg=fixture_generator
- """))
+ script.scratch_path.join("file-egg-req.txt").write(
+ "\n%s\n" % (
+ "git://github.com/alex/django-fixture-generator.git"
+ "#egg=fixture_generator"
+ )
+ )
with pytest.raises(AssertionError):
- script.pip("install", "-vvv", "-r", script.scratch_path / "file-egg-req.txt")
+ script.pip(
+ "install", "-vvv", "-r", script.scratch_path / "file-egg-req.txt"
+ )
def test_relative_requirements_file(script, data):
"""
- Test installing from a requirements file with a relative path with an egg= definition..
+ Test installing from a requirements file with a relative path with an
+ egg= definition..
"""
- url = path_to_url(os.path.join(data.root, "packages", "..", "packages", "FSPkg")) + '#egg=FSPkg'
+ url = path_to_url(
+ os.path.join(data.root, "packages", "..", "packages", "FSPkg")
+ ) + '#egg=FSPkg'
script.scratch_path.join("file-egg-req.txt").write(textwrap.dedent("""\
%s
""" % url))
- result = script.pip('install', '-vvv', '-r', script.scratch_path / 'file-egg-req.txt')
- assert (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, str(result.stdout)
+ result = script.pip(
+ 'install', '-vvv', '-r', script.scratch_path / 'file-egg-req.txt'
+ )
+ assert (
+ 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, (
+ str(result.stdout)
+ )
def test_multiple_requirements_files(script, tmpdir):
@@ -66,14 +79,25 @@ def test_multiple_requirements_files(script, tmpdir):
"""
other_lib_name, other_lib_version = 'anyjson', '0.3'
- script.scratch_path.join("initools-req.txt").write(textwrap.dedent("""\
- -e %s@10#egg=INITools-dev
- -r %s-req.txt""" % (local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")),
- other_lib_name)))
- script.scratch_path.join("%s-req.txt" % other_lib_name).write(textwrap.dedent("""\
- %s<=%s
- """ % (other_lib_name, other_lib_version)))
- result = script.pip('install', '-r', script.scratch_path / 'initools-req.txt')
+ script.scratch_path.join("initools-req.txt").write(
+ textwrap.dedent("""
+ -e %s@10#egg=INITools-dev
+ -r %s-req.txt
+ """) %
+ (
+ local_checkout(
+ 'svn+http://svn.colorstudy.com/INITools/trunk',
+ tmpdir.join("cache"),
+ ),
+ other_lib_name
+ ),
+ )
+ script.scratch_path.join("%s-req.txt" % other_lib_name).write(
+ "%s<=%s" % (other_lib_name, other_lib_version)
+ )
+ result = script.pip(
+ 'install', '-r', script.scratch_path / 'initools-req.txt'
+ )
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
@@ -87,17 +111,23 @@ def test_respect_order_in_requirements_file(script, data):
simple
"""))
- result = script.pip('install', '--no-index', '-f', data.find_links, '-r', script.scratch_path / 'frameworks-req.txt')
+ result = script.pip(
+ 'install', '--no-index', '-f', data.find_links, '-r',
+ script.scratch_path / 'frameworks-req.txt'
+ )
downloaded = [line for line in result.stdout.split('\n')
if 'Downloading/unpacking' in line]
- assert 'parent' in downloaded[0], 'First download should ' \
- 'be "parent" but was "%s"' % downloaded[0]
- assert 'child' in downloaded[1], 'Second download should ' \
- 'be "child" but was "%s"' % downloaded[1]
- assert 'simple' in downloaded[2], 'Third download should ' \
- 'be "simple" but was "%s"' % downloaded[2]
+ assert 'parent' in downloaded[0], (
+ 'First download should be "parent" but was "%s"' % downloaded[0]
+ )
+ assert 'child' in downloaded[1], (
+ 'Second download should be "child" but was "%s"' % downloaded[1]
+ )
+ assert 'simple' in downloaded[2], (
+ 'Third download should be "simple" but was "%s"' % downloaded[2]
+ )
def test_install_local_editable_with_extras(script, data):
@@ -106,16 +136,22 @@ 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, str(result)
- assert script.site_packages/'LocalExtras.egg-link' in res.files_created, str(result)
- assert script.site_packages/'simple' in res.files_created, str(result)
+ 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)
def test_install_local_editable_with_subdirectory(script):
version_pkg_path = _create_test_package_with_subdirectory(script,
'version_subpkg')
- result = script.pip('install', '-e',
- '%s#egg=version_subpkg&subdirectory=version_subpkg' %
- ('git+file://%s' % version_pkg_path,))
+ result = script.pip(
+ 'install', '-e',
+ '%s#egg=version_subpkg&subdirectory=version_subpkg' %
+ ('git+file://%s' % version_pkg_path,)
+ )
result.assert_installed('version-subpkg')
239 tests/functional/test_install_upgrade.py
View
@@ -2,13 +2,12 @@
import sys
import textwrap
-from os.path import join
-
import pytest
-from tests.lib import SRC_DIR
-from tests.lib import (assert_all_changes, pyversion,
- _create_test_package, _change_test_package_version)
+from tests.lib import (
+ assert_all_changes, pyversion, _create_test_package,
+ _change_test_package_version,
+)
from tests.lib.local_repos import local_checkout
@@ -19,7 +18,9 @@ def test_no_upgrade_unless_requested(script):
"""
script.pip('install', 'INITools==0.1', expect_error=True)
result = script.pip('install', 'INITools', expect_error=True)
- assert not result.files_created, 'pip install INITools upgraded when it should not have'
+ assert not result.files_created, (
+ 'pip install INITools upgraded when it should not have'
+ )
def test_upgrade_to_specific_version(script):
@@ -29,9 +30,17 @@ def test_upgrade_to_specific_version(script):
"""
script.pip('install', 'INITools==0.1', expect_error=True)
result = script.pip('install', 'INITools==0.2', expect_error=True)
- assert result.files_created, 'pip install with specific version did not upgrade'
- assert 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' % pyversion in result.files_created
+ assert result.files_created, (
+ 'pip install with specific version did not upgrade'
+ )
+ assert (
+ 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' %
+ pyversion in result.files_created
+ )
def test_upgrade_if_requested(script):
@@ -42,7 +51,10 @@ def test_upgrade_if_requested(script):
script.pip('install', 'INITools==0.1', expect_error=True)
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' % pyversion not in result.files_created
+ assert (
+ script.site_packages/'INITools-0.1-py%s.egg-info' %
+ pyversion not in result.files_created
+ )
def test_upgrade_with_newest_already_installed(script, data):
@@ -51,7 +63,9 @@ def test_upgrade_with_newest_already_installed(script, data):
not be reinstalled and the user should be informed.
"""
script.pip('install', '-f', data.find_links, '--no-index', 'simple')
- result = script.pip('install', '--upgrade', '-f', data.find_links, '--no-index', 'simple')
+ result = script.pip(
+ 'install', '--upgrade', '-f', data.find_links, '--no-index', 'simple'
+ )
assert not result.files_created, 'simple upgraded when it should not have'
assert 'already up-to-date' in result.stdout, result.stdout
@@ -62,8 +76,12 @@ def test_upgrade_force_reinstall_newest(script):
version if --force-reinstall is supplied.
"""
result = script.pip('install', 'INITools')
- assert script.site_packages/ 'initools' in result.files_created, sorted(result.files_created.keys())
- result2 = script.pip('install', '--upgrade',