Merge pull request #2510 from pypa/3.7-tests

3.7 tests passing (and other improvements)
This commit is contained in:
2018-07-03 23:30:22 -04:00
committed by GitHub
15 changed files with 718 additions and 728 deletions
+3
View File
@@ -17,6 +17,9 @@ pytz = "*"
towncrier = {git = "https://github.com/hawkowl/towncrier.git", editable = true, ref = "master"}
parver = "*"
invoke = "*"
jedi = "*"
isort = "*"
rope = "*"
[packages]
Generated
+38 -7
View File
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "0599ae763bc5f1eaa30bd414c1495dc10fdfd3b5b0c109515d71322c8668d7e1"
"sha256": "88d256c1798cc297772ecd3d2152013e0b28201a5364a1c0f8e4dde79b6e200c"
},
"pipfile-spec": 6,
"requires": {},
@@ -163,12 +163,29 @@
"index": "pypi",
"version": "==1.0.0"
},
"isort": {
"hashes": [
"sha256:1153601da39a25b14ddc54955dbbacbb6b2d19135386699e2ad58517953b34af",
"sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8",
"sha256:ec9ef8f4a9bc6f71eec99e1806bfa2de401650d996c59330782b89a5555c1497"
],
"index": "pypi",
"version": "==4.3.4"
},
"itsdangerous": {
"hashes": [
"sha256:cbb3fcf8d3e33df861709ecaf89d9e6629cff0a217bc2848f1b41cd30d360519"
],
"version": "==0.24"
},
"jedi": {
"hashes": [
"sha256:b409ed0f6913a701ed474a614a3bb46e6953639033e31f769ca7581da5bd1ec1",
"sha256:c254b135fb39ad76e78d4d8f92765ebc9bf92cbc76f49e97ade1d5f5121e1f6f"
],
"index": "pypi",
"version": "==0.12.1"
},
"jinja2": {
"hashes": [
"sha256:74c935a1b8bb9a3947c50a54766a969d4846290e1e788ea44c1392163723c3bd",
@@ -212,6 +229,13 @@
],
"version": "==17.1"
},
"parso": {
"hashes": [
"sha256:8105449d86d858e53ce3e0044ede9dd3a395b1c9716c696af8aa3787158ab806",
"sha256:d250235e52e8f9fc5a80cc2a5f804c9fefd886b2e67a2b1099cf085f403f8e33"
],
"version": "==0.3.0"
},
"parver": {
"hashes": [
"sha256:ac4afff688d19d5e1876bb68d4bccc1a1b6a5cc8bd6a646939a14d366695ba15",
@@ -244,7 +268,7 @@
"sha256:d345c8fe681115900d6da8d048ba67c25df42973bda370783cd58826442dcd7c",
"sha256:e160a7fcf25762bb60efc7e171d4497ff1d8d2d75a3d0df7a21b76821ecbf5c5"
],
"markers": "python_version != '3.2.*' and python_version != '3.1.*' and python_version != '3.0.*' and python_version != '3.3.*' and python_version >= '2.7'",
"markers": "python_version >= '2.7' and python_version != '3.1.*' and python_version != '3.2.*' and python_version != '3.0.*' and python_version != '3.3.*'",
"version": "==0.6.0"
},
"py": {
@@ -252,7 +276,7 @@
"sha256:3fd59af7435864e1a243790d322d763925431213b6b8529c6ca71081ace3bbf7",
"sha256:e31fb2767eb657cbde86c454f02e99cb846d3cd9d61b318525140214fdc0e98e"
],
"markers": "python_version != '3.2.*' and python_version != '3.1.*' and python_version != '3.0.*' and python_version != '3.3.*' and python_version >= '2.7'",
"markers": "python_version >= '2.7' and python_version != '3.1.*' and python_version != '3.2.*' and python_version != '3.0.*' and python_version != '3.3.*'",
"version": "==1.5.4"
},
"pycodestyle": {
@@ -340,6 +364,13 @@
],
"version": "==0.8.0"
},
"rope": {
"hashes": [
"sha256:a09edfd2034fd50099a67822f9bd851fbd0f4e98d3b87519f6267b60e50d80d1"
],
"index": "pypi",
"version": "==0.10.7"
},
"six": {
"hashes": [
"sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9",
@@ -375,7 +406,7 @@
"sha256:68ca7ff70785cbe1e7bccc71a48b5b6d965d79ca50629606c7861a21b206d9dd",
"sha256:9de47f375baf1ea07cdb3436ff39d7a9c76042c10a769c52353ec46e4e8fc3b9"
],
"markers": "python_version != '3.2.*' and python_version != '3.1.*' and python_version != '3.0.*' and python_version != '3.3.*' and python_version >= '2.7'",
"markers": "python_version >= '2.7' and python_version != '3.1.*' and python_version != '3.2.*' and python_version != '3.0.*' and python_version != '3.3.*'",
"version": "==1.1.0"
},
"stdeb": {
@@ -409,7 +440,7 @@
"sha256:224291ee0d8c52d91b037fd90806f48c79bcd9994d3b0abc9e44b946a908fccd",
"sha256:77b8424d41b31e68f437c6dd9cd567aebc9a860507cb42fbd880a5f822d966fe"
],
"markers": "python_version >= '2.6' and python_version != '3.0.*' and python_version != '3.1.*'",
"markers": "python_version != '3.1.*' and python_version != '3.0.*' and python_version >= '2.6'",
"version": "==4.23.4"
},
"twine": {
@@ -425,7 +456,7 @@
"sha256:a68ac5e15e76e7e5dd2b8f94007233e01effe3e50e8daddf69acfd81cb686baf",
"sha256:b5725a0bd4ba422ab0e66e89e030c806576753ea3ee08554382c14e685d117b5"
],
"markers": "python_version >= '2.6' and python_version != '3.2.*' and python_version != '3.1.*' and python_version < '4' and python_version != '3.0.*' and python_version != '3.3.*'",
"markers": "python_version != '3.1.*' and python_version < '4' and python_version != '3.2.*' and python_version >= '2.6' and python_version != '3.0.*' and python_version != '3.3.*'",
"version": "==1.23"
},
"virtualenv": {
@@ -433,7 +464,7 @@
"sha256:2ce32cd126117ce2c539f0134eb89de91a8413a29baac49cbab3eb50e2026669",
"sha256:ca07b4c0b54e14a91af9f34d0919790b016923d157afda5efdde55c96718f752"
],
"markers": "python_version != '3.0.*' and python_version != '3.1.*' and python_version != '3.2.*' and python_version >= '2.7'",
"markers": "python_version >= '2.7' and python_version != '3.0.*' and python_version != '3.1.*' and python_version != '3.2.*'",
"version": "==16.0.0"
},
"virtualenv-clone": {
-114
View File
@@ -1,114 +0,0 @@
build: off
version: 1.0.{build}
skip_branch_with_pr: true
init:
- ps: >-
git config --global core.sharedRepository true
git config --global core.longpaths true
git config --global core.autocrlf input
if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
Write-Host "There are newer queued builds for this pull request, skipping build."
Exit-AppveyorBuild
}
If (($env:SKIP_NOTAG -eq "true") -and ($env:APPVEYOR_REPO_TAG -ne "true")) {
Write-Host "Skipping build, not at a tag."
Exit-AppveyorBuild
}
environment:
PYPI_VENDOR_DIR: '.\tests\pypi\'
GIT_ASK_YESNO: 'false'
APPVEYOR_SAVE_CACHE_ON_ERROR: 'true'
APPVEYOR_SKIP_FINALIZE_ON_EXIT: 'true'
SHELL: 'windows'
PYTHON_ARCH: '64'
PYTHONIOENCODING: 'utf-8'
matrix:
- PYTHON: 'C:\Python27-x64'
PYTHON_VERSION: '2.7.x'
TEST_SUITE: 'not install'
- PYTHON: 'C:\Python27-x64'
PYTHON_VERSION: '2.7.x'
TEST_SUITE: 'install'
PYTEST_ADDOPTS: '--cache-clear'
RUN_INTEGRATION_TESTS: 'True'
- PYTHON: 'C:\Python36-x64'
PYTHON_VERSION: '3.6.x'
TEST_SUITE: 'not install'
- PYTHON: 'C:\Python36-x64'
PYTHON_VERSION: '3.6.x'
TEST_SUITE: 'install'
PYTEST_ADDOPTS: '--cache-clear'
RUN_INTEGRATION_TESTS: 'True'
- PYTHON: 'C:\Python37-x64'
PYTHON_VERSION: '3.7.x'
TEST_SUITE: 'not install'
- PYTHON: 'C:\Python37-x64'
PYTHON_VERSION: '3.7.x'
TEST_SUITE: 'install'
PYTEST_ADDOPTS: '--cache-clear'
RUN_INTEGRATION_TESTS: 'True'
install:
- ps: >-
$script_path = Join-Path -path $env:PYTHON -childpath Scripts
$py_exe = Join-Path -path $env:PYTHON -childpath python.exe
$pipenv_exe = Join-Path -path $script_path -childpath pipenv.exe
$env:PATH = "$py_path;$script_path;$env:PATH"
Invoke-Expression "$py_exe -m pip install --upgrade pip invoke"
Invoke-Expression "$py_exe -m pip install -e ."
Invoke-Expression "$pipenv_exe install --dev"
Invoke-Expression "$pipenv_exe --venv"
Invoke-Expression "$pipenv_exe --py"
cache:
- '%LocalAppData%\pip\cache'
- '%LocalAppData%\pipenv\cache'
test_script:
- ps: >-
$script_path = Join-Path -path $env:PYTHON -childpath Scripts
$py_exe = Join-Path -path $env:PYTHON -childpath python.exe
$pipenv_exe = Join-Path -path $script_path -childpath pipenv.exe
$env:PATH = "$py_path;$script_path;$env:PATH"
$invoke_path = Join-Path -path $script_path -childpath invoke.exe
Invoke-Expression "$pipenv_exe run pytest -v -n 4 --ignore=pipenv\patched --ignore=pipenv\vendor -m `"$env:TEST_SUITE`" tests"
If ($env:RUN_INTEGRATION_TESTS -and ($env:PYTHON_VERSION -eq "3.6.x")) {
Invoke-Expression "$py_exe -m pip install invoke parver"
Invoke-Expression "$invoke_path vendoring.update"
}
+1 -5
View File
@@ -252,7 +252,7 @@ def cli(
loc = project.virtualenv_location
echo(
crayons.normal(
u"{0} ({1})...".format(
u"{0} ({1})".format(
crayons.normal("Removing virtualenv", bold=True),
crayons.green(loc),
)
@@ -287,8 +287,6 @@ def cli(
echo(format_help(ctx.get_help()))
@command(
short_help="Installs provided packages and adds them to Pipfile, or (if none is given), installs all packages.",
context_settings=dict(ignore_unknown_options=True, allow_extra_args=True),
@@ -834,8 +832,6 @@ def update(
do_outdated,
do_lock,
do_sync,
ensure_lockfile,
do_install,
project,
)
+53 -60
View File
@@ -125,7 +125,6 @@ project = Project(which=which)
def do_clear():
click.echo(crayons.white("Clearing caches…", bold=True))
import pip._internal.locations
import piptools
try:
shutil.rmtree(PIPENV_CACHE_DIR)
@@ -144,7 +143,7 @@ def load_dot_env():
)
if os.path.isfile(denv):
click.echo(
crayons.normal("Loading .env environment variables...", bold=True),
crayons.normal("Loading .env environment variables", bold=True),
err=True,
)
dotenv.load_dotenv(denv, override=True)
@@ -211,7 +210,7 @@ def import_requirements(r=None, dev=False):
def ensure_environment():
# Skip this on Windows...
# Skip this on Windows
if os.name != "nt":
if "LANG" not in os.environ:
click.echo(
@@ -258,15 +257,15 @@ def ensure_pipfile(validate=True, skip_requirements=False, system=False):
err=True,
)
sys.exit(1)
# If there's a requirements file, but no Pipfile...
# If there's a requirements file, but no Pipfile
if project.requirements_exists and not skip_requirements:
click.echo(
crayons.normal(
u"requirements.txt found, instead of Pipfile! Converting...",
u"requirements.txt found, instead of Pipfile! Converting",
bold=True,
)
)
# Create a Pipfile...
# Create a Pipfile
project.create_pipfile(python=python)
with spinner():
# Import requirements.txt.
@@ -284,7 +283,7 @@ def ensure_pipfile(validate=True, skip_requirements=False, system=False):
)
else:
click.echo(
crayons.normal(u"Creating a Pipfile for this project...", bold=True),
crayons.normal(u"Creating a Pipfile for this project", bold=True),
err=True,
)
# Create the pipfile if it doesn't exist.
@@ -297,8 +296,7 @@ def ensure_pipfile(validate=True, skip_requirements=False, system=False):
# Write changes out to disk.
if changed:
click.echo(
crayons.normal(u"Fixing package names in Pipfile...", bold=True),
err=True,
crayons.normal(u"Fixing package names in Pipfile", bold=True), err=True
)
project.write_toml(p)
@@ -440,7 +438,7 @@ def ensure_python(three=None, python=None):
u"{0}: Python {1} {2}".format(
crayons.red("Warning", bold=True),
crayons.blue(python),
u"was not found on your system...",
u"was not found on your system",
),
err=True,
)
@@ -476,7 +474,7 @@ def ensure_python(three=None, python=None):
crayons.green("CPython {0}".format(version)),
"with pyenv?",
)
# Prompt the user to continue...
# Prompt the user to continue
if not (PIPENV_YES or click.confirm(s, default=True)):
abort()
else:
@@ -487,7 +485,7 @@ def ensure_python(three=None, python=None):
crayons.green(u"CPython {0}".format(version), bold=True),
crayons.normal(u"with pyenv", bold=True),
crayons.normal(u"(this may take a few minutes)"),
crayons.normal(u"...", bold=True),
crayons.normal(u"", bold=True),
)
)
with spinner():
@@ -497,14 +495,14 @@ def ensure_python(three=None, python=None):
timeout=PIPENV_INSTALL_TIMEOUT,
block=False,
)
# Wait until the process has finished...
# Wait until the process has finished
c.block()
try:
assert c.return_code == 0
except AssertionError:
click.echo(u"Something went wrong...")
click.echo(u"Something went wrong")
click.echo(crayons.blue(c.err), err=True)
# Print the results, in a beautiful blue...
# Print the results, in a beautiful blue
click.echo(crayons.blue(c.out), err=True)
# Add new paths to PATH.
activate_pyenv()
@@ -544,7 +542,7 @@ def ensure_virtualenv(three=None, python=None, site_packages=False, pypi_mirror=
if PIPENV_USE_SYSTEM:
click.echo(
crayons.red(
"You are attempting to re-create a virtualenv that "
"You are attempting to recreate a virtualenv that "
"Pipenv did not create. Aborting."
)
)
@@ -556,7 +554,7 @@ def ensure_virtualenv(three=None, python=None, site_packages=False, pypi_mirror=
# If interrupted, cleanup the virtualenv.
cleanup_virtualenv(bare=False)
sys.exit(1)
# If --three, --two, or --python were passed...
# If --three, --two, or --python were passed
elif (python) or (three is not None) or (site_packages is not False):
USING_DEFAULT_PYTHON = False
# Ensure python is installed before deleting existing virtual env
@@ -571,7 +569,7 @@ def ensure_virtualenv(three=None, python=None, site_packages=False, pypi_mirror=
):
abort()
click.echo(
crayons.normal(u"Removing existing virtualenv...", bold=True), err=True
crayons.normal(u"Removing existing virtualenv", bold=True), err=True
)
# Remove the virtualenv.
cleanup_virtualenv(bare=True)
@@ -723,7 +721,7 @@ def do_install_dependencies(
click.echo(crayons.yellow(c.out.strip()))
if verbose:
click.echo(crayons.blue(c.out or c.err))
# The Installation failed...
# The Installation failed
if c.return_code != 0:
# Save the Failed Dependency for later.
failed_deps_list.append((c.dep, c.ignore_hash))
@@ -742,7 +740,7 @@ def do_install_dependencies(
if skip_lock or only or not project.lockfile_exists:
if not bare:
click.echo(
crayons.normal(u"Installing dependencies from Pipfile...", bold=True)
crayons.normal(u"Installing dependencies from Pipfile", bold=True)
)
lockfile = split_file(project._lockfile)
else:
@@ -751,7 +749,7 @@ def do_install_dependencies(
if not bare:
click.echo(
crayons.normal(
u"Installing dependencies from Pipfile.lock ({0})...".format(
u"Installing dependencies from Pipfile.lock ({0})".format(
lockfile["_meta"].get("hash", {}).get("sha256")[-6:]
),
bold=True,
@@ -818,10 +816,10 @@ def do_install_dependencies(
cleanup_procs(procs, concurrent)
procs = []
cleanup_procs(procs, concurrent)
# Iterate over the hopefully-poorly-packaged dependencies...
# Iterate over the hopefully-poorly-packaged dependencies
if failed_deps_list:
click.echo(
crayons.normal(u"Installing initially failed dependencies...", bold=True)
crayons.normal(u"Installing initially failed dependencies", bold=True)
)
for dep, ignore_hash in progress.bar(failed_deps_list, label=INSTALL_LABEL2):
# Use a specific index, if specified.
@@ -838,7 +836,7 @@ def do_install_dependencies(
requirements_dir=requirements_dir,
extra_indexes=extra_indexes,
)
# The Installation failed...
# The Installation failed
if c.return_code != 0:
# We echo both c.out and c.err because pip returns error details on out.
click.echo(crayons.blue(format_pip_output(c.out)))
@@ -873,8 +871,7 @@ def convert_three_to_python(three, python):
def do_create_virtualenv(python=None, site_packages=False, pypi_mirror=None):
"""Creates a virtualenv."""
click.echo(
crayons.normal(u"Creating a virtualenv for this project...", bold=True),
err=True,
crayons.normal(u"Creating a virtualenv for this project", bold=True), err=True
)
click.echo(
u"Pipfile: {0}".format(crayons.red(project.pipfile_location, bold=True)),
@@ -889,7 +886,7 @@ def do_create_virtualenv(python=None, site_packages=False, pypi_mirror=None):
project.virtualenv_location,
"--prompt=({0})".format(project.name),
]
# Pass site-packages flag to virtualenv, if desired...
# Pass site-packages flag to virtualenv, if desired
if site_packages:
cmd.append("--system-site-packages")
else:
@@ -910,7 +907,7 @@ def do_create_virtualenv(python=None, site_packages=False, pypi_mirror=None):
u"{0} {1} {3} {2}".format(
crayons.normal("Using", bold=True),
crayons.red(python, bold=True),
crayons.normal(u"to create virtualenv...", bold=True),
crayons.normal(u"to create virtualenv", bold=True),
crayons.green("({0})".format(python_version(python))),
),
err=True,
@@ -936,10 +933,10 @@ def do_create_virtualenv(python=None, site_packages=False, pypi_mirror=None):
)
sys.exit(1)
click.echo(crayons.blue(c.out), err=True)
# Enable site-packages, if desired...
# Enable site-packages, if desired
if not project.is_venv_in_project() and site_packages:
click.echo(
crayons.normal(u"Making site-packages available...", bold=True), err=True
crayons.normal(u"Making site-packages available", bold=True), err=True
)
os.environ["VIRTUAL_ENV"] = project.virtualenv_location
delegator.run("pipenv run pewtwo toggleglobalsitepackages")
@@ -955,7 +952,7 @@ def parse_download_fname(fname, name):
if fname.endswith(".tar"):
fname, _ = os.path.splitext(fname)
# Substring out package name (plus dash) from file name to get version.
version = fname[len(name) + 1 :]
version = fname[len(name) + 1:]
# Ignore implicit post releases in version number.
if "-" in version and version.split("-")[1].isdigit():
version = version.split("-")[0]
@@ -1053,7 +1050,7 @@ def do_lock(
u"{0} {1} {2}".format(
crayons.normal("Locking"),
crayons.red("[{0}]".format(settings["log_string"])),
crayons.normal("dependencies..."),
crayons.normal("dependencies…"),
),
err=True,
)
@@ -1120,7 +1117,7 @@ def do_lock(
vcs_lockfile.update(dep_lockfile)
lockfile[settings["lockfile_key"]].update(vcs_lockfile)
# Support for --keep-outdated...
# Support for --keep-outdated
if keep_outdated:
for section_name, section in (
("default", project.packages),
@@ -1160,9 +1157,7 @@ def do_purge(bare=False, downloads=False, allow_global=False, verbose=False):
if downloads:
if not bare:
click.echo(
crayons.normal(u"Clearing out downloads directory...", bold=True)
)
click.echo(crayons.normal(u"Clearing out downloads directory…", bold=True))
shutil.rmtree(project.download_location)
return
@@ -1191,9 +1186,7 @@ def do_purge(bare=False, downloads=False, allow_global=False, verbose=False):
actually_installed.append(dep)
if not bare:
click.echo(
u"Found {0} installed package(s), purging...".format(
len(actually_installed)
)
u"Found {0} installed package(s), purging".format(len(actually_installed))
)
command = "{0} uninstall {1} -y".format(
escape_grouped_arguments(which_pip(allow_global=allow_global)),
@@ -1259,9 +1252,9 @@ def do_init(
click.echo(
crayons.red(
u"Pipfile.lock ({0}) out of date, but installation "
u"uses {1}... re-building lockfile must happen in "
u"uses {1} re-building lockfile must happen in "
u"isolation. Please rebuild lockfile in a virtualenv. "
u"Continuing anyway...".format(
u"Continuing anyway".format(
crayons.white(old_hash[-6:]), crayons.white("--system")
),
bold=True,
@@ -1271,7 +1264,7 @@ def do_init(
else:
click.echo(
crayons.red(
u"Pipfile.lock ({0}) out of date, updating to ({1})...".format(
u"Pipfile.lock ({0}) out of date, updating to ({1})".format(
old_hash[-6:], new_hash[-6:]
),
bold=True,
@@ -1302,7 +1295,7 @@ def do_init(
sys.exit(1)
else:
click.echo(
crayons.normal(u"Pipfile.lock not found, creating...", bold=True),
crayons.normal(u"Pipfile.lock not found, creating", bold=True),
err=True,
)
do_lock(
@@ -1376,7 +1369,7 @@ def pip_install(
except (ParseException, ValueError) as e:
click.echo("{0}: {1}".format(crayons.red("WARNING"), e), err=True)
click.echo(
"{0}... You will have to reinstall any packages that failed to install.".format(
"{0} You will have to reinstall any packages that failed to install.".format(
crayons.red("ABORTING INSTALL")
),
err=True,
@@ -1511,7 +1504,7 @@ def system_which(command, mult=False):
_which = "which -a" if not os.name == "nt" else "where"
c = delegator.run("{0} {1}".format(_which, command))
try:
# Which Not found...
# Which Not found
if c.return_code == 127:
click.echo(
"{}: the {} system utility is required for Pipenv to find Python installations properly."
@@ -1650,7 +1643,7 @@ def ensure_lockfile(keep_outdated=False, pypi_mirror=None):
if new_hash != old_hash:
click.echo(
crayons.red(
u"Pipfile.lock ({0}) out of date, updating to ({1})...".format(
u"Pipfile.lock ({0}) out of date, updating to ({1})".format(
old_hash[-6:], new_hash[-6:]
),
bold=True,
@@ -1778,7 +1771,7 @@ def do_install(
# Download requirements file
click.echo(
crayons.normal(
u"Remote requirements file provided! Downloading...", bold=True
u"Remote requirements file provided! Downloading", bold=True
),
err=True,
)
@@ -1802,7 +1795,7 @@ def do_install(
error, traceback = None, None
click.echo(
crayons.normal(
u"Requirements file provided! Importing into Pipfile...", bold=True
u"Requirements file provided! Importing into Pipfile", bold=True
),
err=True,
)
@@ -1834,7 +1827,7 @@ def do_install(
sys.exit(1)
if code:
click.echo(
crayons.normal(u"Discovering imports from local codebase...", bold=True)
crayons.normal(u"Discovering imports from local codebase", bold=True)
)
for req in import_from_code(code):
click.echo(" Found {0}!".format(crayons.green(req)))
@@ -1931,7 +1924,7 @@ def do_install(
for package_name in package_names:
click.echo(
crayons.normal(
u"Installing {0}...".format(crayons.green(package_name, bold=True)),
u"Installing {0}".format(crayons.green(package_name, bold=True)),
bold=True,
)
)
@@ -1995,7 +1988,7 @@ def do_install(
crayons.green(package_name, bold=True),
crayons.normal("to Pipfile's", bold=True),
crayons.red("[dev-packages]" if dev else "[packages]", bold=True),
crayons.normal("...", bold=True),
crayons.normal("", bold=True),
)
)
# Add the package to the Pipfile.
@@ -2049,7 +2042,7 @@ def do_uninstall(
# Un-install all dependencies, if --all was provided.
if all is True:
click.echo(
crayons.normal(u"Un-installing all packages from virtualenv...", bold=True)
crayons.normal(u"Un-installing all packages from virtualenv", bold=True)
)
do_purge(allow_global=system, verbose=verbose)
sys.exit(0)
@@ -2065,7 +2058,7 @@ def do_uninstall(
sys.exit(0)
click.echo(
crayons.normal(
u"Un-installing {0}...".format(crayons.red("[dev-packages]")), bold=True
u"Un-installing {0}".format(crayons.red("[dev-packages]")), bold=True
)
)
package_names = project.dev_packages.keys()
@@ -2073,7 +2066,7 @@ def do_uninstall(
click.echo(crayons.red("No package provided!"), err=True)
sys.exit(1)
for package_name in package_names:
click.echo(u"Un-installing {0}...".format(crayons.green(package_name)))
click.echo(u"Un-installing {0}".format(crayons.green(package_name)))
cmd = "{0} uninstall {1} -y".format(
escape_grouped_arguments(which_pip(allow_global=system)), package_name
)
@@ -2095,7 +2088,7 @@ def do_uninstall(
continue
click.echo(
u"Removing {0} from Pipfile...".format(crayons.green(package_name))
u"Removing {0} from Pipfile".format(crayons.green(package_name))
)
# Remove package from both packages and dev-packages.
project.remove_package_from_pipfile(package_name, dev=True)
@@ -2141,7 +2134,7 @@ def inline_activate_virtualenv():
if not activate_this or not os.path.exists(activate_this):
click.echo(
u"{0}: activate_this.py not found. Your environment is most "
u"certainly not activated. Continuing anyway..."
u"certainly not activated. Continuing anyway"
u"".format(crayons.red("Warning", bold=True)),
err=True,
)
@@ -2152,7 +2145,7 @@ def inline_activate_virtualenv():
# Catch all errors, just in case.
except Exception:
click.echo(
u"{0}: There was an unexpected error while activating your virtualenv. Continuing anyway..."
u"{0}: There was an unexpected error while activating your virtualenv. Continuing anyway"
"".format(crayons.red("Warning", bold=True)),
err=True,
)
@@ -2261,7 +2254,7 @@ def do_check(
sys.exit(1)
else:
sys.exit(0)
click.echo(crayons.normal(u"Checking PEP 508 requirements...", bold=True))
click.echo(crayons.normal(u"Checking PEP 508 requirements", bold=True))
if system:
python = system_which("python")
else:
@@ -2297,7 +2290,7 @@ def do_check(
sys.exit(1)
else:
click.echo(crayons.green("Passed!"))
click.echo(crayons.normal(u"Checking installed package safety...", bold=True))
click.echo(crayons.normal(u"Checking installed package safety", bold=True))
path = pep508checker.__file__.rstrip("cdo")
path = os.sep.join(__file__.split(os.sep)[:-1] + ["patched", "safety.zip"])
if not system:
@@ -2558,7 +2551,7 @@ def do_clean(
else:
click.echo(
crayons.white(
"Uninstalling {0}...".format(repr(apparent_bad_package)), bold=True
"Uninstalling {0}".format(repr(apparent_bad_package)), bold=True
)
)
# Uninstall the package.
+1 -1
View File
@@ -1,2 +1,2 @@
[pytest]
addopts = -n auto tests
norecursedirs = vendor patched
+3 -3
View File
@@ -11,15 +11,15 @@ export PYTHONIOENCODING="utf-8"
export LANG=C.UTF-8
prefix() {
sed "s/^/ $1: /"
sed "s/^/ $1: /"
}
if [[ ! -z "$TEST_SUITE" ]]; then
echo "Using TEST_SUITE=$TEST_SUITE"
fi
export PATH="~/.local/bin:$PATH"
pip uninstall -y pipenv
export PATH="$HOME/.local/bin:$PATH"
# pip uninstall -y pipenv
echo "Installing Pipenv…"
pip install -e "$(pwd)" --upgrade
pipenv install --deploy --dev
+134 -127
View File
@@ -1,4 +1,3 @@
import contextlib
import os
from pipenv.utils import temp_environ
@@ -17,53 +16,55 @@ from flaky import flaky
def test_basic_setup(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
with PipenvInstance(pipfile=False) as p:
c = p.pipenv('install requests')
c = p.pipenv("install requests")
assert c.return_code == 0
assert 'requests' in p.pipfile['packages']
assert 'requests' in p.lockfile['default']
assert 'chardet' in p.lockfile['default']
assert 'idna' in p.lockfile['default']
assert 'urllib3' in p.lockfile['default']
assert 'certifi' in p.lockfile['default']
assert "requests" in p.pipfile["packages"]
assert "requests" in p.lockfile["default"]
assert "chardet" in p.lockfile["default"]
assert "idna" in p.lockfile["default"]
assert "urllib3" in p.lockfile["default"]
assert "certifi" in p.lockfile["default"]
@pytest.mark.install
@flaky
def test_basic_install(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
c = p.pipenv('install requests')
c = p.pipenv("install requests")
assert c.return_code == 0
assert 'requests' in p.pipfile['packages']
assert 'requests' in p.lockfile['default']
assert 'chardet' in p.lockfile['default']
assert 'idna' in p.lockfile['default']
assert 'urllib3' in p.lockfile['default']
assert 'certifi' in p.lockfile['default']
assert "requests" in p.pipfile["packages"]
assert "requests" in p.lockfile["default"]
assert "chardet" in p.lockfile["default"]
assert "idna" in p.lockfile["default"]
assert "urllib3" in p.lockfile["default"]
assert "certifi" in p.lockfile["default"]
@pytest.mark.install
@flaky
def test_mirror_install(PipenvInstance, pypi):
with temp_environ(), PipenvInstance(chdir=True) as p:
mirror_url = os.environ.pop('PIPENV_TEST_INDEX', "https://pypi.python.org/simple")
assert 'pypi.org' not in mirror_url
mirror_url = os.environ.pop(
"PIPENV_TEST_INDEX", "https://pypi.python.org/simple"
)
assert "pypi.org" not in mirror_url
# This should sufficiently demonstrate the mirror functionality
# since pypi.org is the default when PIPENV_TEST_INDEX is unset.
c = p.pipenv('install requests --pypi-mirror {0}'.format(mirror_url))
c = p.pipenv("install requests --pypi-mirror {0}".format(mirror_url))
assert c.return_code == 0
# Ensure the --pypi-mirror parameter hasn't altered the Pipfile or Pipfile.lock sources
assert len(p.pipfile['source']) == 1
assert len(p.pipfile["source"]) == 1
assert len(p.lockfile["_meta"]["sources"]) == 1
assert 'https://pypi.org/simple' == p.pipfile['source'][0]['url']
assert 'https://pypi.org/simple' == p.lockfile['_meta']['sources'][0]['url']
assert "https://pypi.org/simple" == p.pipfile["source"][0]["url"]
assert "https://pypi.org/simple" == p.lockfile["_meta"]["sources"][0]["url"]
assert 'requests' in p.pipfile['packages']
assert 'requests' in p.lockfile['default']
assert 'chardet' in p.lockfile['default']
assert 'idna' in p.lockfile['default']
assert 'urllib3' in p.lockfile['default']
assert 'certifi' in p.lockfile['default']
assert "requests" in p.pipfile["packages"]
assert "requests" in p.lockfile["default"]
assert "chardet" in p.lockfile["default"]
assert "idna" in p.lockfile["default"]
assert "urllib3" in p.lockfile["default"]
assert "certifi" in p.lockfile["default"]
@pytest.mark.install
@@ -72,21 +73,21 @@ def test_mirror_install(PipenvInstance, pypi):
def test_bad_mirror_install(PipenvInstance, pypi):
with temp_environ(), PipenvInstance(chdir=True) as p:
# This demonstrates that the mirror parameter is being used
os.environ.pop('PIPENV_TEST_INDEX', None)
c = p.pipenv('install requests --pypi-mirror https://pypi.example.org')
os.environ.pop("PIPENV_TEST_INDEX", None)
c = p.pipenv("install requests --pypi-mirror https://pypi.example.org")
assert c.return_code != 0
@pytest.mark.complex
@pytest.mark.lock
@pytest.mark.skip(reason='Does not work unless you can explicitly install into py2')
@pytest.mark.skip(reason="Does not work unless you can explicitly install into py2")
def test_complex_lock(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
c = p.pipenv('install apscheduler')
c = p.pipenv("install apscheduler")
assert c.return_code == 0
assert 'apscheduler' in p.pipfile['packages']
assert 'funcsigs' in p.lockfile[u'default']
assert 'futures' in p.lockfile[u'default']
assert "apscheduler" in p.pipfile["packages"]
assert "funcsigs" in p.lockfile[u"default"]
assert "futures" in p.lockfile[u"default"]
@pytest.mark.dev
@@ -94,16 +95,16 @@ def test_complex_lock(PipenvInstance, pypi):
@flaky
def test_basic_dev_install(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
c = p.pipenv('install requests --dev')
c = p.pipenv("install requests --dev")
assert c.return_code == 0
assert 'requests' in p.pipfile['dev-packages']
assert 'requests' in p.lockfile['develop']
assert 'chardet' in p.lockfile['develop']
assert 'idna' in p.lockfile['develop']
assert 'urllib3' in p.lockfile['develop']
assert 'certifi' in p.lockfile['develop']
assert "requests" in p.pipfile["dev-packages"]
assert "requests" in p.lockfile["develop"]
assert "chardet" in p.lockfile["develop"]
assert "idna" in p.lockfile["develop"]
assert "urllib3" in p.lockfile["develop"]
assert "certifi" in p.lockfile["develop"]
c = p.pipenv('run python -m requests.help')
c = p.pipenv("run python -m requests.help")
assert c.return_code == 0
@@ -113,7 +114,7 @@ def test_basic_dev_install(PipenvInstance, pypi):
def test_install_without_dev(PipenvInstance, pypi):
"""Ensure that running `pipenv install` doesn't install dev packages"""
with PipenvInstance(pypi=pypi, chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
with open(p.pipfile_path, "w") as f:
contents = """
[packages]
six = "*"
@@ -122,12 +123,12 @@ six = "*"
pytz = "*"
""".strip()
f.write(contents)
c = p.pipenv('install')
c = p.pipenv("install")
assert c.return_code == 0
assert 'six' in p.pipfile['packages']
assert 'pytz' in p.pipfile['dev-packages']
assert 'six' in p.lockfile['default']
assert 'pytz' in p.lockfile['develop']
assert "six" in p.pipfile["packages"]
assert "pytz" in p.pipfile["dev-packages"]
assert "six" in p.lockfile["default"]
assert "pytz" in p.lockfile["develop"]
c = p.pipenv('run python -c "import pytz"')
assert c.return_code != 0
c = p.pipenv('run python -c "import six"')
@@ -138,18 +139,18 @@ pytz = "*"
@flaky
def test_install_without_dev_section(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
with open(p.pipfile_path, 'w') as f:
with open(p.pipfile_path, "w") as f:
contents = """
[packages]
six = "*"
""".strip()
f.write(contents)
c = p.pipenv('install')
c = p.pipenv("install")
assert c.return_code == 0
assert 'six' in p.pipfile['packages']
assert p.pipfile.get('dev-packages', {}) == {}
assert 'six' in p.lockfile['default']
assert p.lockfile['develop'] == {}
assert "six" in p.pipfile["packages"]
assert p.pipfile.get("dev-packages", {}) == {}
assert "six" in p.lockfile["default"]
assert p.lockfile["develop"] == {}
c = p.pipenv('run python -c "import six"')
assert c.return_code == 0
@@ -159,16 +160,16 @@ six = "*"
@flaky
def test_extras_install(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi, chdir=True) as p:
c = p.pipenv('install requests[socks]')
c = p.pipenv("install requests[socks]")
assert c.return_code == 0
assert 'requests' in p.pipfile['packages']
assert 'extras' in p.pipfile['packages']['requests']
assert "requests" in p.pipfile["packages"]
assert "extras" in p.pipfile["packages"]["requests"]
assert 'requests' in p.lockfile['default']
assert 'chardet' in p.lockfile['default']
assert 'idna' in p.lockfile['default']
assert 'urllib3' in p.lockfile['default']
assert 'pysocks' in p.lockfile['default']
assert "requests" in p.lockfile["default"]
assert "chardet" in p.lockfile["default"]
assert "idna" in p.lockfile["default"]
assert "urllib3" in p.lockfile["default"]
assert "pysocks" in p.lockfile["default"]
@pytest.mark.install
@@ -176,16 +177,16 @@ def test_extras_install(PipenvInstance, pypi):
@flaky
def test_windows_pinned_pipfile(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
with open(p.pipfile_path, 'w') as f:
with open(p.pipfile_path, "w") as f:
contents = """
[packages]
tablib = "<0.12"
requests = "==2.19.1"
""".strip()
f.write(contents)
c = p.pipenv('install')
c = p.pipenv("install")
assert c.return_code == 0
assert 'tablib' in p.pipfile['packages']
assert 'tablib' in p.lockfile['default']
assert "requests" in p.pipfile["packages"]
assert "requests" in p.lockfile["default"]
@pytest.mark.install
@@ -194,16 +195,16 @@ tablib = "<0.12"
@flaky
def test_backup_resolver(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
with open(p.pipfile_path, 'w') as f:
with open(p.pipfile_path, "w") as f:
contents = """
[packages]
"ibm-db-sa-py3" = "==0.3.1-1"
""".strip()
f.write(contents)
c = p.pipenv('install')
c = p.pipenv("install")
assert c.return_code == 0
assert 'ibm-db-sa-py3' in p.lockfile['default']
assert "ibm-db-sa-py3" in p.lockfile["default"]
@pytest.mark.run
@@ -211,21 +212,21 @@ def test_backup_resolver(PipenvInstance, pypi):
@flaky
def test_alternative_version_specifier(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
with open(p.pipfile_path, 'w') as f:
with open(p.pipfile_path, "w") as f:
contents = """
[packages]
requests = {version = "*"}
""".strip()
f.write(contents)
c = p.pipenv('install')
c = p.pipenv("install")
assert c.return_code == 0
assert 'requests' in p.lockfile['default']
assert 'idna' in p.lockfile['default']
assert 'urllib3' in p.lockfile['default']
assert 'certifi' in p.lockfile['default']
assert 'chardet' in p.lockfile['default']
assert "requests" in p.lockfile["default"]
assert "idna" in p.lockfile["default"]
assert "urllib3" in p.lockfile["default"]
assert "certifi" in p.lockfile["default"]
assert "chardet" in p.lockfile["default"]
c = p.pipenv('run python -c "import requests; import idna; import certifi;"')
assert c.return_code == 0
@@ -235,7 +236,7 @@ requests = {version = "*"}
@pytest.mark.install
def test_bad_packages(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
c = p.pipenv('install NotAPackage')
c = p.pipenv("install NotAPackage")
assert c.return_code > 0
@@ -248,25 +249,25 @@ def test_requirements_to_pipfile(PipenvInstance, pypi):
with PipenvInstance(pipfile=False, chdir=True, pypi=pypi) as p:
# Write a requirements file
with open('requirements.txt', 'w') as f:
f.write('requests[socks]==2.18.1\n')
with open("requirements.txt", "w") as f:
f.write("requests[socks]==2.18.1\n")
c = p.pipenv('install')
c = p.pipenv("install")
assert c.return_code == 0
print(c.out)
print(c.err)
print(delegator.run('ls -l').out)
print(delegator.run("ls -l").out)
# assert stuff in pipfile
assert 'requests' in p.pipfile['packages']
assert 'extras' in p.pipfile['packages']['requests']
assert "requests" in p.pipfile["packages"]
assert "extras" in p.pipfile["packages"]["requests"]
# assert stuff in lockfile
assert 'requests' in p.lockfile['default']
assert 'chardet' in p.lockfile['default']
assert 'idna' in p.lockfile['default']
assert 'urllib3' in p.lockfile['default']
assert 'pysocks' in p.lockfile['default']
assert "requests" in p.lockfile["default"]
assert "chardet" in p.lockfile["default"]
assert "idna" in p.lockfile["default"]
assert "urllib3" in p.lockfile["default"]
assert "pysocks" in p.lockfile["default"]
@pytest.mark.install
@@ -278,31 +279,31 @@ def test_skip_requirements_when_pipfile(PipenvInstance, pypi):
2. A Pipfile already exists when we run `pipenv install`.
"""
with PipenvInstance(chdir=True, pypi=pypi) as p:
with open('requirements.txt', 'w') as f:
f.write('requests==2.18.1\n')
c = p.pipenv('install six')
with open("requirements.txt", "w") as f:
f.write("requests==2.18.1\n")
c = p.pipenv("install six")
assert c.return_code == 0
with open(p.pipfile_path, 'w') as f:
with open(p.pipfile_path, "w") as f:
contents = """
[packages]
six = "*"
tablib = "<0.12"
""".strip()
f.write(contents)
c = p.pipenv('install')
assert 'tablib' in p.pipfile['packages']
assert 'tablib' in p.lockfile['default']
assert 'six' in p.pipfile['packages']
assert 'six' in p.lockfile['default']
assert 'requests' not in p.pipfile['packages']
assert 'requests' not in p.lockfile['default']
c = p.pipenv("install")
assert "tablib" in p.pipfile["packages"]
assert "tablib" in p.lockfile["default"]
assert "six" in p.pipfile["packages"]
assert "six" in p.lockfile["default"]
assert "requests" not in p.pipfile["packages"]
assert "requests" not in p.lockfile["default"]
@pytest.mark.cli
@pytest.mark.clean
def test_clean_on_empty_venv(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
c = p.pipenv('clean')
c = p.pipenv("clean")
assert c.return_code == 0
@@ -311,27 +312,29 @@ def test_install_does_not_extrapolate_environ(PipenvInstance, pypi):
"""Ensure environment variables are not expanded in lock file.
"""
with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p:
os.environ['PYPI_URL'] = pypi.url
os.environ["PYPI_URL"] = pypi.url
with open(p.pipfile_path, 'w') as f:
f.write("""
with open(p.pipfile_path, "w") as f:
f.write(
"""
[[source]]
url = '${PYPI_URL}/simple'
verify_ssl = true
name = 'mockpi'
""")
"""
)
# Ensure simple install does not extrapolate.
c = p.pipenv('install')
c = p.pipenv("install")
assert c.return_code == 0
assert p.pipfile['source'][0]['url'] == '${PYPI_URL}/simple'
assert p.lockfile['_meta']['sources'][0]['url'] == '${PYPI_URL}/simple'
assert p.pipfile["source"][0]["url"] == "${PYPI_URL}/simple"
assert p.lockfile["_meta"]["sources"][0]["url"] == "${PYPI_URL}/simple"
# Ensure package install does not extrapolate.
c = p.pipenv('install six')
c = p.pipenv("install six")
assert c.return_code == 0
assert p.pipfile['source'][0]['url'] == '${PYPI_URL}/simple'
assert p.lockfile['_meta']['sources'][0]['url'] == '${PYPI_URL}/simple'
assert p.pipfile["source"][0]["url"] == "${PYPI_URL}/simple"
assert p.lockfile["_meta"]["sources"][0]["url"] == "${PYPI_URL}/simple"
@pytest.mark.editable
@@ -339,9 +342,9 @@ name = 'mockpi'
@pytest.mark.install
def test_editable_no_args(PipenvInstance):
with PipenvInstance() as p:
c = p.pipenv('install -e')
c = p.pipenv("install -e")
assert c.return_code != 0
assert 'Please provide path to editable package' in c.err
assert "Please provide path to editable package" in c.err
@pytest.mark.install
@@ -353,33 +356,37 @@ def test_install_venv_project_directory(PipenvInstance, pypi):
workon_home based virtualenv for this test.
"""
with PipenvInstance(pypi=pypi, chdir=True) as p:
with temp_environ(), TemporaryDirectory(prefix='pipenv-', suffix='temp_workon_home') as workon_home:
os.environ['WORKON_HOME'] = workon_home.name
if 'PIPENV_VENV_IN_PROJECT' in os.environ:
del os.environ['PIPENV_VENV_IN_PROJECT']
c = p.pipenv('install six')
with temp_environ(), TemporaryDirectory(
prefix="pipenv-", suffix="temp_workon_home"
) as workon_home:
os.environ["WORKON_HOME"] = workon_home.name
if "PIPENV_VENV_IN_PROJECT" in os.environ:
del os.environ["PIPENV_VENV_IN_PROJECT"]
c = p.pipenv("install six")
assert c.return_code == 0
project = Project()
assert Path(project.virtualenv_location).joinpath('.project').exists()
assert Path(project.virtualenv_location).joinpath(".project").exists()
@pytest.mark.deploy
@pytest.mark.system
def test_system_and_deploy_work(PipenvInstance, pypi):
with PipenvInstance(chdir=True, pypi=pypi) as p:
c = p.pipenv('install six requests')
c = p.pipenv("install six requests")
assert c.return_code == 0
c = p.pipenv('--rm')
c = p.pipenv("--rm")
assert c.return_code == 0
c = delegator.run('virtualenv .venv')
c = delegator.run("virtualenv .venv")
assert c.return_code == 0
c = p.pipenv('install --system --deploy')
c = p.pipenv("install --system --deploy")
assert c.return_code == 0
c = p.pipenv('--rm')
c = p.pipenv("--rm")
assert c.return_code == 0
Path(p.pipfile_path).write_text(u"""
Path(p.pipfile_path).write_text(
u"""
[packages]
requests
""".strip())
c = p.pipenv('install --system')
""".strip()
)
c = p.pipenv("install --system")
assert c.return_code == 0
+88 -81
View File
@@ -13,16 +13,17 @@ from flaky import flaky
@pytest.mark.extras
@pytest.mark.install
@pytest.mark.local
@pytest.mark.parametrize('line, pipfile', [
['-e .[dev]', {'testpipenv': {'path': '.', 'editable': True, 'extras': ['dev']}}]
])
@pytest.mark.parametrize(
"line, pipfile",
[["-e .[dev]", {"testpipenv": {"path": ".", "editable": True, "extras": ["dev"]}}]],
)
def test_local_extras_install(PipenvInstance, pypi, line, pipfile):
"""Ensure -e .[extras] installs.
"""
with PipenvInstance(pypi=pypi, chdir=True) as p:
project = Project()
setup_py = os.path.join(p.path, 'setup.py')
with open(setup_py, 'w') as fh:
setup_py = os.path.join(p.path, "setup.py")
with open(setup_py, "w") as fh:
contents = """
from setuptools import setup, find_packages
setup(
@@ -39,21 +40,21 @@ zip_safe=False
)
""".strip()
fh.write(contents)
project.write_toml({'packages': pipfile, 'dev-packages': {}})
c = p.pipenv('install')
project.write_toml({"packages": pipfile, "dev-packages": {}})
c = p.pipenv("install")
assert c.return_code == 0
assert 'testpipenv' in p.lockfile['default']
assert p.lockfile['default']['testpipenv']['extras'] == ['dev']
assert 'six' in p.lockfile['default']
c = p.pipenv('--rm')
assert "testpipenv" in p.lockfile["default"]
assert p.lockfile["default"]["testpipenv"]["extras"] == ["dev"]
assert "six" in p.lockfile["default"]
c = p.pipenv("--rm")
assert c.return_code == 0
project.write_toml({'packages': {}, 'dev-packages': {}})
c = p.pipenv('install {0}'.format(line))
project.write_toml({"packages": {}, "dev-packages": {}})
c = p.pipenv("install {0}".format(line))
assert c.return_code == 0
assert 'testpipenv' in p.pipfile['packages']
assert p.pipfile['packages']['testpipenv']['path'] == '.'
assert p.pipfile['packages']['testpipenv']['extras'] == ['dev']
assert 'six' in p.lockfile['default']
assert "testpipenv" in p.pipfile["packages"]
assert p.pipfile["packages"]["testpipenv"]["path"] == "."
assert p.pipfile["packages"]["testpipenv"]["extras"] == ["dev"]
assert "six" in p.lockfile["default"]
@pytest.mark.e
@@ -62,23 +63,23 @@ zip_safe=False
def test_e_dot(PipenvInstance, pip_src_dir):
with PipenvInstance() as p:
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
c = p.pipenv('install -e \'{0}\' --dev'.format(path))
c = p.pipenv("install -e '{0}' --dev".format(path))
assert c.return_code == 0
key = [k for k in p.pipfile['dev-packages'].keys()][0]
assert 'path' in p.pipfile['dev-packages'][key]
assert 'requests' in p.lockfile['develop']
key = [k for k in p.pipfile["dev-packages"].keys()][0]
assert "path" in p.pipfile["dev-packages"][key]
assert "requests" in p.lockfile["develop"]
@pytest.mark.install
@flaky
def test_multiprocess_bug_and_install(PipenvInstance, pypi):
with temp_environ():
os.environ['PIPENV_MAX_SUBPROCESS'] = '2'
os.environ["PIPENV_MAX_SUBPROCESS"] = "2"
with PipenvInstance(pypi=pypi, chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
with open(p.pipfile_path, "w") as f:
contents = """
[packages]
pytz = "*"
@@ -87,12 +88,12 @@ urllib3 = "*"
""".strip()
f.write(contents)
c = p.pipenv('install')
c = p.pipenv("install")
assert c.return_code == 0
assert 'pytz' in p.lockfile['default']
assert 'six' in p.lockfile['default']
assert 'urllib3' in p.lockfile['default']
assert "pytz" in p.lockfile["default"]
assert "six" in p.lockfile["default"]
assert "urllib3" in p.lockfile["default"]
c = p.pipenv('run python -c "import six; import pytz; import urllib3;"')
assert c.return_code == 0
@@ -104,7 +105,7 @@ urllib3 = "*"
def test_sequential_mode(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi, chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
with open(p.pipfile_path, "w") as f:
contents = """
[packages]
six = "*"
@@ -113,12 +114,12 @@ pytz = "*"
""".strip()
f.write(contents)
c = p.pipenv('install --sequential')
c = p.pipenv("install --sequential")
assert c.return_code == 0
assert 'six' in p.lockfile['default']
assert 'pytz' in p.lockfile['default']
assert 'urllib3' in p.lockfile['default']
assert "six" in p.lockfile["default"]
assert "pytz" in p.lockfile["default"]
assert "urllib3" in p.lockfile["default"]
c = p.pipenv('run python -c "import six; import urllib3; import pytz;"')
assert c.return_code == 0
@@ -128,7 +129,7 @@ pytz = "*"
@pytest.mark.run
def test_normalize_name_install(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
with open(p.pipfile_path, 'w') as f:
with open(p.pipfile_path, "w") as f:
contents = """
# Pre comment
[packages]
@@ -136,22 +137,22 @@ Requests = "==2.14.0" # Inline comment
"""
f.write(contents)
c = p.pipenv('install')
c = p.pipenv("install")
assert c.return_code == 0
c = p.pipenv('install requests')
c = p.pipenv("install requests")
assert c.return_code == 0
assert 'requests' not in p.pipfile['packages']
assert p.pipfile['packages']['Requests'] == '==2.14.0'
c = p.pipenv('install requests==2.18.4')
assert "requests" not in p.pipfile["packages"]
assert p.pipfile["packages"]["Requests"] == "==2.14.0"
c = p.pipenv("install requests==2.18.4")
assert c.return_code == 0
assert p.pipfile['packages']['Requests'] == '==2.18.4'
c = p.pipenv('install python_DateUtil')
assert p.pipfile["packages"]["Requests"] == "==2.18.4"
c = p.pipenv("install python_DateUtil")
assert c.return_code == 0
assert 'python-dateutil' in p.pipfile['packages']
assert "python-dateutil" in p.pipfile["packages"]
contents = open(p.pipfile_path).read()
assert '# Pre comment' in contents
assert '# Inline comment' in contents
assert "# Pre comment" in contents
assert "# Inline comment" in contents
@pytest.mark.files
@@ -161,66 +162,70 @@ Requests = "==2.14.0" # Inline comment
def test_local_package(PipenvInstance, pip_src_dir, pypi, testsroot):
"""This test ensures that local packages (directories with a setup.py)
installed in editable mode have their dependencies resolved as well"""
file_name = 'tablib-0.12.1.tar.gz'
package = 'tablib-0.12.1'
file_name = "requests-2.19.1.tar.gz"
package = "requests-2.19.1"
# Not sure where travis/appveyor run tests from
source_path = os.path.abspath(os.path.join(testsroot, 'test_artifacts', file_name))
source_path = os.path.abspath(os.path.join(testsroot, "test_artifacts", file_name))
with PipenvInstance(chdir=True, pypi=pypi) as p:
# This tests for a bug when installing a zipfile in the current dir
copy_to = os.path.join(p.path, file_name)
shutil.copy(source_path, copy_to)
import tarfile
with tarfile.open(copy_to, 'r:gz') as tgz:
with tarfile.open(copy_to, "r:gz") as tgz:
tgz.extractall(path=p.path)
c = p.pipenv('install -e {0}'.format(package))
c = p.pipenv("install -e {0}".format(package))
assert c.return_code == 0
assert all(pkg in p.lockfile['default'] for pkg in ['xlrd', 'xlwt', 'pyyaml', 'odfpy'])
assert all(
pkg in p.lockfile["default"]
for pkg in ["urllib3", "idna", "certifi", "chardet"]
)
@pytest.mark.files
@flaky
def test_local_zipfiles(PipenvInstance, pypi, testsroot):
file_name = 'tablib-0.12.1.tar.gz'
file_name = "requests-2.19.1.tar.gz"
# Not sure where travis/appveyor run tests from
source_path = os.path.abspath(os.path.join(testsroot, 'test_artifacts', file_name))
source_path = os.path.abspath(os.path.join(testsroot, "test_artifacts", file_name))
with PipenvInstance(chdir=True, pypi=pypi) as p:
# This tests for a bug when installing a zipfile in the current dir
shutil.copy(source_path, os.path.join(p.path, file_name))
c = p.pipenv('install {}'.format(file_name))
c = p.pipenv("install {}".format(file_name))
assert c.return_code == 0
key = [k for k in p.pipfile['packages'].keys()][0]
dep = p.pipfile['packages'][key]
key = [k for k in p.pipfile["packages"].keys()][0]
dep = p.pipfile["packages"][key]
assert 'file' in dep or 'path' in dep
assert "file" in dep or "path" in dep
assert c.return_code == 0
key = [k for k in p.lockfile['default'].keys()][0]
dep = p.lockfile['default'][key]
key = [k for k in p.lockfile["default"].keys()][0]
dep = p.lockfile["default"][key]
assert 'file' in dep or 'path' in dep
assert "file" in dep or "path" in dep
@pytest.mark.files
@flaky
def test_relative_paths(PipenvInstance, pypi, testsroot):
file_name = 'tablib-0.12.1.tar.gz'
source_path = os.path.abspath(os.path.join(testsroot, 'test_artifacts', file_name))
file_name = "requests-2.19.1.tar.gz"
source_path = os.path.abspath(os.path.join(testsroot, "test_artifacts", file_name))
with PipenvInstance(pypi=pypi) as p:
artifact_dir = 'artifacts'
artifact_dir = "artifacts"
artifact_path = os.path.join(p.path, artifact_dir)
mkdir_p(artifact_path)
shutil.copy(source_path, os.path.join(artifact_path, file_name))
# Test installing a relative path in a subdirectory
c = p.pipenv('install {}/{}'.format(artifact_dir, file_name))
c = p.pipenv("install {}/{}".format(artifact_dir, file_name))
assert c.return_code == 0
key = next(k for k in p.pipfile['packages'].keys())
dep = p.pipfile['packages'][key]
key = next(k for k in p.pipfile["packages"].keys())
dep = p.pipfile["packages"][key]
assert 'path' in dep
assert Path('.', artifact_dir, file_name) == Path(dep['path'])
assert "path" in dep
assert Path(".", artifact_dir, file_name) == Path(dep["path"])
assert c.return_code == 0
@@ -229,34 +234,36 @@ def test_relative_paths(PipenvInstance, pypi, testsroot):
@flaky
def test_install_local_file_collision(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
target_package = 'alembic'
target_package = "alembic"
fake_file = os.path.join(p.path, target_package)
with open(fake_file, 'w') as f:
f.write('')
c = p.pipenv('install {}'.format(target_package))
with open(fake_file, "w") as f:
f.write("")
c = p.pipenv("install {}".format(target_package))
assert c.return_code == 0
assert target_package in p.pipfile['packages']
assert p.pipfile['packages'][target_package] == '*'
assert target_package in p.lockfile['default']
assert target_package in p.pipfile["packages"]
assert p.pipfile["packages"][target_package] == "*"
assert target_package in p.lockfile["default"]
@pytest.mark.url
@pytest.mark.install
def test_install_local_uri_special_character(PipenvInstance, testsroot):
file_name = 'six-1.11.0+mkl-py2.py3-none-any.whl'
source_path = os.path.abspath(os.path.join(testsroot, 'test_artifacts', file_name))
file_name = "six-1.11.0+mkl-py2.py3-none-any.whl"
source_path = os.path.abspath(os.path.join(testsroot, "test_artifacts", file_name))
with PipenvInstance() as p:
artifact_dir = 'artifacts'
artifact_dir = "artifacts"
artifact_path = os.path.join(p.path, artifact_dir)
mkdir_p(artifact_path)
shutil.copy(source_path, os.path.join(artifact_path, file_name))
with open(p.pipfile_path, 'w') as f:
with open(p.pipfile_path, "w") as f:
contents = """
# Pre comment
[packages]
six = {{path = "./artifacts/{}"}}
""".format(file_name)
six = {{path = "./artifacts/{}"}}
""".format(
file_name
)
f.write(contents.strip())
c = p.pipenv('install')
c = p.pipenv("install")
assert c.return_code == 0
assert 'six' in p.lockfile['default']
assert "six" in p.lockfile["default"]
+94 -89
View File
@@ -11,15 +11,18 @@ from pipenv._compat import Path
@flaky
def test_basic_vcs_install(PipenvInstance, pip_src_dir, pypi):
with PipenvInstance(pypi=pypi, chdir=True) as p:
c = p.pipenv('install git+https://github.com/benjaminp/six.git@1.11.0#egg=six')
c = p.pipenv("install git+https://github.com/benjaminp/six.git@1.11.0#egg=six")
assert c.return_code == 0
# edge case where normal package starts with VCS name shouldn't be flagged as vcs
c = p.pipenv('install gitdb2')
c = p.pipenv("install gitdb2")
assert c.return_code == 0
assert all(package in p.pipfile['packages'] for package in ['six', 'gitdb2'])
assert 'git' in p.pipfile['packages']['six']
assert p.lockfile['default']['six'] == {"git": "https://github.com/benjaminp/six.git", "ref": "15e31431af97e5e64b80af0a3f598d382bcdd49a"}
assert 'gitdb2' in p.lockfile['default']
assert all(package in p.pipfile["packages"] for package in ["six", "gitdb2"])
assert "git" in p.pipfile["packages"]["six"]
assert p.lockfile["default"]["six"] == {
"git": "https://github.com/benjaminp/six.git",
"ref": "15e31431af97e5e64b80af0a3f598d382bcdd49a",
}
assert "gitdb2" in p.lockfile["default"]
@pytest.mark.files
@@ -28,23 +31,24 @@ def test_basic_vcs_install(PipenvInstance, pip_src_dir, pypi):
@flaky
def test_urls_work(PipenvInstance, pypi, pip_src_dir):
with PipenvInstance(pypi=pypi) as p:
c = p.pipenv('install https://github.com/divio/django-cms/archive/release/3.4.x.zip')
c = p.pipenv(
"install https://github.com/divio/django-cms/archive/release/3.4.x.zip"
)
assert c.return_code == 0
dep = list(p.pipfile['packages'].values())[0]
assert 'file' in dep, p.pipfile
dep = list(p.pipfile["packages"].values())[0]
assert "file" in dep, p.pipfile
dep = list(p.lockfile['default'].values())[0]
assert 'file' in dep, p.lockfile
dep = list(p.lockfile["default"].values())[0]
assert "file" in dep, p.lockfile
@pytest.mark.files
@pytest.mark.urls
def test_file_urls_work(PipenvInstance, pip_src_dir):
with PipenvInstance(chdir=True) as p:
whl = (
Path(__file__).parent.parent
.joinpath('pypi', 'six', 'six-1.11.0-py2.py3-none-any.whl')
whl = Path(__file__).parent.parent.joinpath(
"pypi", "six", "six-1.11.0-py2.py3-none-any.whl"
)
try:
whl = whl.resolve()
@@ -53,9 +57,8 @@ def test_file_urls_work(PipenvInstance, pip_src_dir):
wheel_url = whl.as_uri()
c = p.pipenv('install "{0}"'.format(wheel_url))
assert c.return_code == 0
assert 'six' in p.pipfile['packages']
assert 'file' in p.pipfile['packages']['six']
assert "six" in p.pipfile["packages"]
assert "file" in p.pipfile["packages"]["six"]
@pytest.mark.files
@@ -63,38 +66,16 @@ def test_file_urls_work(PipenvInstance, pip_src_dir):
@pytest.mark.needs_internet
def test_local_vcs_urls_work(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi, chdir=True) as p:
six_path = Path(p.path).joinpath('six').absolute()
six_path = Path(p.path).joinpath("six").absolute()
c = delegator.run(
'git clone '
'https://github.com/benjaminp/six.git {0}'.format(six_path)
"git clone " "https://github.com/benjaminp/six.git {0}".format(six_path)
)
assert c.return_code == 0
c = p.pipenv('install git+{0}#egg=six'.format(six_path.as_uri()))
c = p.pipenv("install git+{0}#egg=six".format(six_path.as_uri()))
assert c.return_code == 0
@pytest.mark.files
@pytest.mark.urls
@pytest.mark.needs_internet
@flaky
def test_install_remote_requirements(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
# using a github hosted requirements.txt file
c = p.pipenv('install -r https://raw.githubusercontent.com/kennethreitz/pipenv/3688148ac7cfecefb085c474b092c31d791952c1/tests/test_artifacts/requirements.txt')
assert c.return_code == 0
# check Pipfile with versions
assert 'requests' in p.pipfile['packages']
assert p.pipfile['packages']['requests'] == u'==2.18.4'
assert 'records' in p.pipfile['packages']
assert p.pipfile['packages']['records'] == u'==0.5.2'
# check Pipfile.lock
assert 'requests' in p.lockfile['default']
assert 'records' in p.lockfile['default']
@pytest.mark.e
@pytest.mark.vcs
@pytest.mark.install
@@ -102,16 +83,18 @@ def test_install_remote_requirements(PipenvInstance, pypi):
@flaky
def test_editable_vcs_install(PipenvInstance, pip_src_dir, pypi):
with PipenvInstance(pypi=pypi) as p:
c = p.pipenv('install -e git+https://github.com/requests/requests.git#egg=requests')
c = p.pipenv(
"install -e git+https://github.com/requests/requests.git#egg=requests"
)
assert c.return_code == 0
assert 'requests' in p.pipfile['packages']
assert 'git' in p.pipfile['packages']['requests']
assert 'editable' in p.pipfile['packages']['requests']
assert 'editable' in p.lockfile['default']['requests']
assert 'chardet' in p.lockfile['default']
assert 'idna' in p.lockfile['default']
assert 'urllib3' in p.lockfile['default']
assert 'certifi' in p.lockfile['default']
assert "requests" in p.pipfile["packages"]
assert "git" in p.pipfile["packages"]["requests"]
assert "editable" in p.pipfile["packages"]["requests"]
assert "editable" in p.lockfile["default"]["requests"]
assert "chardet" in p.lockfile["default"]
assert "idna" in p.lockfile["default"]
assert "urllib3" in p.lockfile["default"]
assert "certifi" in p.lockfile["default"]
@pytest.mark.install
@@ -123,13 +106,18 @@ def test_install_editable_git_tag(PipenvInstance, pip_src_dir, pypi):
# This uses the real PyPI since we need Internet to access the Git
# dependency anyway.
with PipenvInstance(pypi=pypi) as p:
c = p.pipenv('install -e git+https://github.com/benjaminp/six.git@1.11.0#egg=six')
c = p.pipenv(
"install -e git+https://github.com/benjaminp/six.git@1.11.0#egg=six"
)
assert c.return_code == 0
assert 'six' in p.pipfile['packages']
assert 'six' in p.lockfile['default']
assert 'git' in p.lockfile['default']['six']
assert p.lockfile['default']['six']['git'] == 'https://github.com/benjaminp/six.git'
assert 'ref' in p.lockfile['default']['six']
assert "six" in p.pipfile["packages"]
assert "six" in p.lockfile["default"]
assert "git" in p.lockfile["default"]["six"]
assert (
p.lockfile["default"]["six"]["git"]
== "https://github.com/benjaminp/six.git"
)
assert "ref" in p.lockfile["default"]["six"]
@pytest.mark.install
@@ -137,7 +125,7 @@ def test_install_editable_git_tag(PipenvInstance, pip_src_dir, pypi):
@pytest.mark.needs_internet
def test_install_named_index_alias(PipenvInstance):
with PipenvInstance() as p:
with open(p.pipfile_path, 'w') as f:
with open(p.pipfile_path, "w") as f:
contents = """
[[source]]
url = "https://pypi.org/simple"
@@ -155,7 +143,7 @@ six = "*"
[dev-packages]
""".strip()
f.write(contents)
c = p.pipenv('install pipenv-test-private-package --index testpypi')
c = p.pipenv("install pipenv-test-private-package --index testpypi")
assert c.return_code == 0
@@ -164,23 +152,27 @@ six = "*"
@pytest.mark.needs_internet
def test_install_local_vcs_not_in_lockfile(PipenvInstance, pip_src_dir):
with PipenvInstance(chdir=True) as p:
six_path = os.path.join(p.path, 'six')
c = delegator.run('git clone https://github.com/benjaminp/six.git {0}'.format(six_path))
six_path = os.path.join(p.path, "six")
c = delegator.run(
"git clone https://github.com/benjaminp/six.git {0}".format(six_path)
)
assert c.return_code == 0
c = p.pipenv('install -e ./six')
c = p.pipenv("install -e ./six")
assert c.return_code == 0
six_key = list(p.pipfile['packages'].keys())[0]
c = p.pipenv('install -e git+https://github.com/requests/requests.git#egg=requests')
six_key = list(p.pipfile["packages"].keys())[0]
c = p.pipenv(
"install -e git+https://github.com/requests/requests.git#egg=requests"
)
assert c.return_code == 0
c = p.pipenv('lock')
c = p.pipenv("lock")
assert c.return_code == 0
assert 'requests' in p.pipfile['packages']
assert 'requests' in p.lockfile['default']
assert "requests" in p.pipfile["packages"]
assert "requests" in p.lockfile["default"]
# This is the hash of ./six
assert six_key in p.pipfile['packages']
assert six_key in p.lockfile['default']
assert six_key in p.pipfile["packages"]
assert six_key in p.lockfile["default"]
# The hash isn't a hash anymore, its actually the name of the package (we now resolve this)
assert 'six' in p.pipfile['packages']
assert "six" in p.pipfile["packages"]
@pytest.mark.vcs
@@ -188,19 +180,27 @@ def test_install_local_vcs_not_in_lockfile(PipenvInstance, pip_src_dir):
@pytest.mark.needs_internet
def test_get_vcs_refs(PipenvInstance, pip_src_dir):
with PipenvInstance(chdir=True) as p:
c = p.pipenv('install -e git+https://github.com/benjaminp/six.git@1.9.0#egg=six')
c = p.pipenv(
"install -e git+https://github.com/benjaminp/six.git@1.9.0#egg=six"
)
assert c.return_code == 0
assert 'six' in p.pipfile['packages']
assert 'six' in p.lockfile['default']
assert p.lockfile['default']['six']['ref'] == '5efb522b0647f7467248273ec1b893d06b984a59'
assert "six" in p.pipfile["packages"]
assert "six" in p.lockfile["default"]
assert (
p.lockfile["default"]["six"]["ref"]
== "5efb522b0647f7467248273ec1b893d06b984a59"
)
pipfile = Path(p.pipfile_path)
new_content = pipfile.read_bytes().replace(b'1.9.0', b'1.11.0')
new_content = pipfile.read_bytes().replace(b"1.9.0", b"1.11.0")
pipfile.write_bytes(new_content)
c = p.pipenv('lock')
c = p.pipenv("lock")
assert c.return_code == 0
assert p.lockfile['default']['six']['ref'] == '15e31431af97e5e64b80af0a3f598d382bcdd49a'
assert 'six' in p.pipfile['packages']
assert 'six' in p.lockfile['default']
assert (
p.lockfile["default"]["six"]["ref"]
== "15e31431af97e5e64b80af0a3f598d382bcdd49a"
)
assert "six" in p.pipfile["packages"]
assert "six" in p.lockfile["default"]
@pytest.mark.vcs
@@ -212,8 +212,9 @@ def test_vcs_entry_supersedes_non_vcs(PipenvInstance, pip_src_dir):
the resolution graph of non-editable vcs dependencies.
"""
with PipenvInstance(chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
f.write("""
with open(p.pipfile_path, "w") as f:
f.write(
"""
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
@@ -222,11 +223,15 @@ name = "pypi"
[packages]
PyUpdater = "*"
PyInstaller = {ref = "develop", git = "https://github.com/pyinstaller/pyinstaller.git"}
""".strip())
p.pipenv('install')
installed_packages = ['PyUpdater', 'PyInstaller']
assert all([k in p.pipfile['packages'] for k in installed_packages])
assert all([k.lower() in p.lockfile['default'] for k in installed_packages])
assert all([k in p.lockfile['default']['pyinstaller'] for k in ['ref', 'git']])
assert p.lockfile['default']['pyinstaller'].get('ref') is not None
assert p.lockfile['default']['pyinstaller']['git'] == "https://github.com/pyinstaller/pyinstaller.git"
""".strip()
)
p.pipenv("install")
installed_packages = ["PyUpdater", "PyInstaller"]
assert all([k in p.pipfile["packages"] for k in installed_packages])
assert all([k.lower() in p.lockfile["default"] for k in installed_packages])
assert all([k in p.lockfile["default"]["pyinstaller"] for k in ["ref", "git"]])
assert p.lockfile["default"]["pyinstaller"].get("ref") is not None
assert (
p.lockfile["default"]["pyinstaller"]["git"]
== "https://github.com/pyinstaller/pyinstaller.git"
)
+70 -68
View File
@@ -11,25 +11,25 @@ import pytest
@pytest.mark.install
def test_uninstall(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
c = p.pipenv('install requests')
c = p.pipenv("install requests")
assert c.return_code == 0
assert 'requests' in p.pipfile['packages']
assert 'requests' in p.lockfile['default']
assert 'chardet' in p.lockfile['default']
assert 'idna' in p.lockfile['default']
assert 'urllib3' in p.lockfile['default']
assert 'certifi' in p.lockfile['default']
assert "requests" in p.pipfile["packages"]
assert "requests" in p.lockfile["default"]
assert "chardet" in p.lockfile["default"]
assert "idna" in p.lockfile["default"]
assert "urllib3" in p.lockfile["default"]
assert "certifi" in p.lockfile["default"]
c = p.pipenv('uninstall requests')
c = p.pipenv("uninstall requests")
assert c.return_code == 0
assert 'requests' not in p.pipfile['dev-packages']
assert 'requests' not in p.lockfile['develop']
assert 'chardet' not in p.lockfile['develop']
assert 'idna' not in p.lockfile['develop']
assert 'urllib3' not in p.lockfile['develop']
assert 'certifi' not in p.lockfile['develop']
assert "requests" not in p.pipfile["dev-packages"]
assert "requests" not in p.lockfile["develop"]
assert "chardet" not in p.lockfile["develop"]
assert "idna" not in p.lockfile["develop"]
assert "urllib3" not in p.lockfile["develop"]
assert "certifi" not in p.lockfile["develop"]
c = p.pipenv('run python -m requests.help')
c = p.pipenv("run python -m requests.help")
assert c.return_code > 0
@@ -39,38 +39,40 @@ def test_uninstall(PipenvInstance, pypi):
def test_mirror_uninstall(PipenvInstance, pypi):
with temp_environ(), PipenvInstance(chdir=True) as p:
mirror_url = os.environ.pop('PIPENV_TEST_INDEX', "https://pypi.python.org/simple")
assert 'pypi.org' not in mirror_url
mirror_url = os.environ.pop(
"PIPENV_TEST_INDEX", "https://pypi.python.org/simple"
)
assert "pypi.org" not in mirror_url
c = p.pipenv('install requests --pypi-mirror {0}'.format(mirror_url))
c = p.pipenv("install requests --pypi-mirror {0}".format(mirror_url))
assert c.return_code == 0
assert 'requests' in p.pipfile['packages']
assert 'requests' in p.lockfile['default']
assert 'chardet' in p.lockfile['default']
assert 'idna' in p.lockfile['default']
assert 'urllib3' in p.lockfile['default']
assert 'certifi' in p.lockfile['default']
assert "requests" in p.pipfile["packages"]
assert "requests" in p.lockfile["default"]
assert "chardet" in p.lockfile["default"]
assert "idna" in p.lockfile["default"]
assert "urllib3" in p.lockfile["default"]
assert "certifi" in p.lockfile["default"]
# Ensure the --pypi-mirror parameter hasn't altered the Pipfile or Pipfile.lock sources
assert len(p.pipfile['source']) == 1
assert len(p.pipfile["source"]) == 1
assert len(p.lockfile["_meta"]["sources"]) == 1
assert 'https://pypi.org/simple' == p.pipfile['source'][0]['url']
assert 'https://pypi.org/simple' == p.lockfile['_meta']['sources'][0]['url']
assert "https://pypi.org/simple" == p.pipfile["source"][0]["url"]
assert "https://pypi.org/simple" == p.lockfile["_meta"]["sources"][0]["url"]
c = p.pipenv('uninstall requests --pypi-mirror {0}'.format(mirror_url))
c = p.pipenv("uninstall requests --pypi-mirror {0}".format(mirror_url))
assert c.return_code == 0
assert 'requests' not in p.pipfile['dev-packages']
assert 'requests' not in p.lockfile['develop']
assert 'chardet' not in p.lockfile['develop']
assert 'idna' not in p.lockfile['develop']
assert 'urllib3' not in p.lockfile['develop']
assert 'certifi' not in p.lockfile['develop']
assert "requests" not in p.pipfile["dev-packages"]
assert "requests" not in p.lockfile["develop"]
assert "chardet" not in p.lockfile["develop"]
assert "idna" not in p.lockfile["develop"]
assert "urllib3" not in p.lockfile["develop"]
assert "certifi" not in p.lockfile["develop"]
# Ensure the --pypi-mirror parameter hasn't altered the Pipfile or Pipfile.lock sources
assert len(p.pipfile['source']) == 1
assert len(p.pipfile["source"]) == 1
assert len(p.lockfile["_meta"]["sources"]) == 1
assert 'https://pypi.org/simple' == p.pipfile['source'][0]['url']
assert 'https://pypi.org/simple' == p.lockfile['_meta']['sources'][0]['url']
assert "https://pypi.org/simple" == p.pipfile["source"][0]["url"]
assert "https://pypi.org/simple" == p.lockfile["_meta"]["sources"][0]["url"]
c = p.pipenv('run python -m requests.help')
c = p.pipenv("run python -m requests.help")
assert c.return_code > 0
@@ -78,19 +80,19 @@ def test_mirror_uninstall(PipenvInstance, pypi):
@pytest.mark.uninstall
@pytest.mark.install
def test_uninstall_all_local_files(PipenvInstance, testsroot):
file_name = 'tablib-0.12.1.tar.gz'
file_name = "requests-2.19.1.tar.gz"
# Not sure where travis/appveyor run tests from
source_path = os.path.abspath(os.path.join(testsroot, 'test_artifacts', file_name))
source_path = os.path.abspath(os.path.join(testsroot, "test_artifacts", file_name))
with PipenvInstance() as p:
shutil.copy(source_path, os.path.join(p.path, file_name))
os.mkdir(os.path.join(p.path, "tablib"))
c = p.pipenv('install {}'.format(file_name))
os.mkdir(os.path.join(p.path, "requests"))
c = p.pipenv("install {}".format(file_name))
assert c.return_code == 0
c = p.pipenv('uninstall --all')
c = p.pipenv("uninstall --all")
assert c.return_code == 0
assert 'tablib' in c.out
assert 'tablib' not in p.pipfile['packages']
assert "requests" in c.out
assert "requests" not in p.pipfile["packages"]
@pytest.mark.run
@@ -98,29 +100,29 @@ def test_uninstall_all_local_files(PipenvInstance, testsroot):
@pytest.mark.install
def test_uninstall_all_dev(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
c = p.pipenv('install --dev requests six')
c = p.pipenv("install --dev requests six")
assert c.return_code == 0
c = p.pipenv('install pytz')
c = p.pipenv("install pytz")
assert c.return_code == 0
assert 'pytz' in p.pipfile['packages']
assert 'requests' in p.pipfile['dev-packages']
assert 'six' in p.pipfile['dev-packages']
assert 'pytz' in p.lockfile['default']
assert 'requests' in p.lockfile['develop']
assert 'six' in p.lockfile['develop']
assert "pytz" in p.pipfile["packages"]
assert "requests" in p.pipfile["dev-packages"]
assert "six" in p.pipfile["dev-packages"]
assert "pytz" in p.lockfile["default"]
assert "requests" in p.lockfile["develop"]
assert "six" in p.lockfile["develop"]
c = p.pipenv('uninstall --all-dev')
c = p.pipenv("uninstall --all-dev")
assert c.return_code == 0
assert 'requests' not in p.pipfile['dev-packages']
assert 'six' not in p.pipfile['dev-packages']
assert 'requests' not in p.lockfile['develop']
assert 'six' not in p.lockfile['develop']
assert 'pytz' in p.pipfile['packages']
assert 'pytz' in p.lockfile['default']
assert "requests" not in p.pipfile["dev-packages"]
assert "six" not in p.pipfile["dev-packages"]
assert "requests" not in p.lockfile["develop"]
assert "six" not in p.lockfile["develop"]
assert "pytz" in p.pipfile["packages"]
assert "pytz" in p.lockfile["default"]
c = p.pipenv('run python -m requests.help')
c = p.pipenv("run python -m requests.help")
assert c.return_code > 0
c = p.pipenv('run python -c "import pytz"')
@@ -131,7 +133,7 @@ def test_uninstall_all_dev(PipenvInstance, pypi):
@pytest.mark.run
def test_normalize_name_uninstall(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
with open(p.pipfile_path, 'w') as f:
with open(p.pipfile_path, "w") as f:
contents = """
# Pre comment
[packages]
@@ -140,12 +142,12 @@ python_DateUtil = "*" # Inline comment
"""
f.write(contents)
c = p.pipenv('install')
c = p.pipenv("install")
assert c.return_code == 0
c = p.pipenv('uninstall python_dateutil')
assert 'Requests' in p.pipfile['packages']
assert 'python_DateUtil' not in p.pipfile['packages']
c = p.pipenv("uninstall python_dateutil")
assert "Requests" in p.pipfile["packages"]
assert "python_DateUtil" not in p.pipfile["packages"]
contents = open(p.pipfile_path).read()
assert '# Pre comment' in contents
assert '# Inline comment' in contents
assert "# Pre comment" in contents
assert "# Inline comment" in contents
Binary file not shown.
-1
View File
@@ -1,2 +1 @@
requests==2.18.4
records==0.5.2
Binary file not shown.
+233 -172
View File
@@ -8,109 +8,122 @@ import pipenv.utils
# Pipfile format <-> requirements.txt format.
DEP_PIP_PAIRS = [
({'requests': '*'}, 'requests'),
({'requests': {'extras': ['socks'], 'version': '*'}}, 'requests[socks]'),
({'django': '>1.10'}, 'django>1.10'),
({'Django': '>1.10'}, 'Django>1.10'),
({"requests": "*"}, "requests"),
({"requests": {"extras": ["socks"], "version": "*"}}, "requests[socks]"),
({"django": ">1.10"}, "django>1.10"),
({"Django": ">1.10"}, "Django>1.10"),
({"requests": {"extras": ["socks"], "version": ">1.10"}}, "requests[socks]>1.10"),
({"requests": {"extras": ["socks"], "version": "==1.10"}}, "requests[socks]==1.10"),
(
{'requests': {'extras': ['socks'], 'version': '>1.10'}},
'requests[socks]>1.10',
{
"pinax": {
"git": "git://github.com/pinax/pinax.git",
"ref": "1.4",
"editable": True,
}
},
"-e git+git://github.com/pinax/pinax.git@1.4#egg=pinax",
),
(
{'requests': {'extras': ['socks'], 'version': '==1.10'}},
'requests[socks]==1.10',
{"pinax": {"git": "git://github.com/pinax/pinax.git", "ref": "1.4"}},
"git+git://github.com/pinax/pinax.git@1.4#egg=pinax",
),
(
{'pinax': {
'git': 'git://github.com/pinax/pinax.git',
'ref': '1.4',
'editable': True,
}},
'-e git+git://github.com/pinax/pinax.git@1.4#egg=pinax',
( # Mercurial.
{
"MyProject": {
"hg": "http://hg.myproject.org/MyProject",
"ref": "da39a3ee5e6b",
}
},
"hg+http://hg.myproject.org/MyProject@da39a3ee5e6b#egg=MyProject",
),
(
{'pinax': {'git': 'git://github.com/pinax/pinax.git', 'ref': '1.4'}},
'git+git://github.com/pinax/pinax.git@1.4#egg=pinax',
),
( # Mercurial.
{'MyProject': {
'hg': 'http://hg.myproject.org/MyProject', 'ref': 'da39a3ee5e6b',
}},
'hg+http://hg.myproject.org/MyProject@da39a3ee5e6b#egg=MyProject',
),
( # SVN.
{'MyProject': {
'svn': 'svn://svn.myproject.org/svn/MyProject', 'editable': True,
}},
'-e svn+svn://svn.myproject.org/svn/MyProject#egg=MyProject',
( # SVN.
{
"MyProject": {
"svn": "svn://svn.myproject.org/svn/MyProject",
"editable": True,
}
},
"-e svn+svn://svn.myproject.org/svn/MyProject#egg=MyProject",
),
(
# Extras in url
{'discord.py': {
'file': 'https://github.com/Rapptz/discord.py/archive/rewrite.zip',
'extras': ['voice']
}},
'https://github.com/Rapptz/discord.py/archive/rewrite.zip#egg=discord.py[voice]',
{
"discord.py": {
"file": "https://github.com/Rapptz/discord.py/archive/rewrite.zip",
"extras": ["voice"],
}
},
"https://github.com/Rapptz/discord.py/archive/rewrite.zip#egg=discord.py[voice]",
),
(
{'requests': {
'git': 'https://github.com/requests/requests.git',
'ref': 'master', 'extras': ['security'],
'editable': False
}},
'git+https://github.com/requests/requests.git@master#egg=requests[security]',
{
"requests": {
"git": "https://github.com/requests/requests.git",
"ref": "master",
"extras": ["security"],
"editable": False,
}
},
"git+https://github.com/requests/requests.git@master#egg=requests[security]",
),
]
@pytest.mark.utils
@pytest.mark.parametrize('deps, expected', DEP_PIP_PAIRS)
@pytest.mark.parametrize("deps, expected", DEP_PIP_PAIRS)
def test_convert_deps_to_pip(deps, expected):
assert pipenv.utils.convert_deps_to_pip(deps, r=False) == [expected]
@pytest.mark.utils
@pytest.mark.parametrize('deps, expected', [
# This one should be collapsed and treated as {'requests': '*'}.
({'requests': {}}, 'requests'),
# Hash value should be passed into the result.
(
{'FooProject': {
'version': '==1.2',
'hash': 'sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824',
}},
'FooProject==1.2 --hash=sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824',
),
(
{'FooProject': {
'version': '==1.2',
'extras': ['stuff'],
'hash': 'sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824',
}},
'FooProject[stuff]==1.2 --hash=sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
),
(
{'requests': {
'git': 'https://github.com/requests/requests.git',
'ref': 'master', 'extras': ['security'],
}},
'git+https://github.com/requests/requests.git@master#egg=requests[security]',
),
])
@pytest.mark.parametrize(
"deps, expected",
[
# This one should be collapsed and treated as {'requests': '*'}.
({"requests": {}}, "requests"),
# Hash value should be passed into the result.
(
{
"FooProject": {
"version": "==1.2",
"hash": "sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
}
},
"FooProject==1.2 --hash=sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
),
(
{
"FooProject": {
"version": "==1.2",
"extras": ["stuff"],
"hash": "sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
}
},
"FooProject[stuff]==1.2 --hash=sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
),
(
{
"requests": {
"git": "https://github.com/requests/requests.git",
"ref": "master",
"extras": ["security"],
}
},
"git+https://github.com/requests/requests.git@master#egg=requests[security]",
),
],
)
def test_convert_deps_to_pip_one_way(deps, expected):
assert pipenv.utils.convert_deps_to_pip(deps, r=False) == [expected]
@pytest.mark.skipif(
isinstance(u'', str),
reason="don't need to test if unicode is str",
)
@pytest.mark.skipif(isinstance(u"", str), reason="don't need to test if unicode is str")
@pytest.mark.utils
def test_convert_deps_to_pip_unicode():
deps = {u'django': u'==1.10'}
deps = {u"django": u"==1.10"}
deps = pipenv.utils.convert_deps_to_pip(deps, r=False)
assert deps[0] == 'django==1.10'
assert deps[0] == "django==1.10"
class TestUtils:
@@ -118,17 +131,17 @@ class TestUtils:
@pytest.mark.utils
@pytest.mark.parametrize(
'version, specified_ver, expected',
"version, specified_ver, expected",
[
('*', '*', True),
('2.1.6', '==2.1.4', False),
('20160913', '>=20140815', True),
("*", "*", True),
("2.1.6", "==2.1.4", False),
("20160913", ">=20140815", True),
(
'1.4',
{'svn': 'svn://svn.myproj.org/svn/MyProj', 'version': '==1.4'},
"1.4",
{"svn": "svn://svn.myproj.org/svn/MyProj", "version": "==1.4"},
True,
),
('2.13.0', {'extras': ['socks'], 'version': '==2.12.4'}, False),
("2.13.0", {"extras": ["socks"], "version": "==2.12.4"}, False),
],
)
def test_is_required_version(self, version, specified_ver, expected):
@@ -136,16 +149,16 @@ class TestUtils:
@pytest.mark.utils
@pytest.mark.parametrize(
'entry, expected',
"entry, expected",
[
({'git': 'package.git', 'ref': 'v0.0.1'}, True),
({'hg': 'https://package.com/package', 'ref': 'v1.2.3'}, True),
('*', False),
({'some_value': 5, 'other_value': object()}, False),
('package', False),
('git+https://github.com/requests/requests.git#egg=requests', True),
('git+git@github.com:requests/requests.git#egg=requests', True),
('gitdb2', False),
({"git": "package.git", "ref": "v0.0.1"}, True),
({"hg": "https://package.com/package", "ref": "v1.2.3"}, True),
("*", False),
({"some_value": 5, "other_value": object()}, False),
("package", False),
("git+https://github.com/requests/requests.git#egg=requests", True),
("git+git@github.com:requests/requests.git#egg=requests", True),
("gitdb2", False),
],
)
@pytest.mark.vcs
@@ -155,28 +168,28 @@ class TestUtils:
@pytest.mark.utils
def test_split_file(self):
pipfile_dict = {
'packages': {
'requests': {'git': 'https://github.com/kennethreitz/requests.git'},
'Flask': '*',
'tablib': {'path': '.', 'editable': True},
"packages": {
"requests": {"git": "https://github.com/kennethreitz/requests.git"},
"Flask": "*",
"tablib": {"path": ".", "editable": True},
},
'dev-packages': {
'Django': '==1.10',
'click': {'svn': 'https://svn.notareal.com/click'},
'crayons': {'hg': 'https://hg.alsonotreal.com/crayons'},
"dev-packages": {
"Django": "==1.10",
"click": {"svn": "https://svn.notareal.com/click"},
"crayons": {"hg": "https://hg.alsonotreal.com/crayons"},
},
}
split_dict = pipenv.utils.split_file(pipfile_dict)
assert list(split_dict['packages'].keys()) == ['Flask']
assert split_dict['packages-vcs'] == {
'requests': {'git': 'https://github.com/kennethreitz/requests.git'}
assert list(split_dict["packages"].keys()) == ["Flask"]
assert split_dict["packages-vcs"] == {
"requests": {"git": "https://github.com/kennethreitz/requests.git"}
}
assert split_dict['packages-editable'] == {
'tablib': {'path': '.', 'editable': True}
assert split_dict["packages-editable"] == {
"tablib": {"path": ".", "editable": True}
}
assert list(split_dict['dev-packages'].keys()) == ['Django']
assert 'click' in split_dict['dev-packages-vcs']
assert 'crayons' in split_dict['dev-packages-vcs']
assert list(split_dict["dev-packages"].keys()) == ["Django"]
assert "click" in split_dict["dev-packages-vcs"]
assert "crayons" in split_dict["dev-packages-vcs"]
@pytest.mark.utils
def test_python_version_from_bad_path(self):
@@ -188,28 +201,31 @@ class TestUtils:
@pytest.mark.utils
@pytest.mark.parametrize(
'version_output, version',
"version_output, version",
[
('Python 3.6.2', '3.6.2'),
('Python 3.6.2 :: Continuum Analytics, Inc.', '3.6.2'),
('Python 3.6.20 :: Continuum Analytics, Inc.', '3.6.20'),
('Python 3.5.3 (3f6eaa010fce78cc7973bdc1dfdb95970f08fed2, Jan 13 2018, 18:14:01)\n[PyPy 5.10.1 with GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]', '3.5.3')
("Python 3.6.2", "3.6.2"),
("Python 3.6.2 :: Continuum Analytics, Inc.", "3.6.2"),
("Python 3.6.20 :: Continuum Analytics, Inc.", "3.6.20"),
(
"Python 3.5.3 (3f6eaa010fce78cc7973bdc1dfdb95970f08fed2, Jan 13 2018, 18:14:01)\n[PyPy 5.10.1 with GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]",
"3.5.3",
),
],
)
@patch('delegator.run')
@patch("delegator.run")
def test_python_version_output_variants(
self, mocked_delegator, version_output, version
):
run_ret = Mock()
run_ret.out = version_output
mocked_delegator.return_value = run_ret
assert pipenv.utils.python_version('some/path') == version
assert pipenv.utils.python_version("some/path") == version
@pytest.mark.utils
@pytest.mark.windows
@pytest.mark.skipif(os.name != 'nt', reason='Windows test only')
@pytest.mark.skipif(os.name != "nt", reason="Windows test only")
def test_windows_shellquote(self):
test_path = 'C:\Program Files\Python36\python.exe'
test_path = "C:\Program Files\Python36\python.exe"
expected_path = '"C:\\\\Program Files\\\\Python36\\\\python.exe"'
assert pipenv.utils.escape_grouped_arguments(test_path) == expected_path
@@ -222,8 +238,8 @@ class TestUtils:
@pytest.mark.utils
def test_download_file(self):
url = "https://github.com/kennethreitz/pipenv/blob/master/README.rst"
output = "test_download.rst"
url = "https://github.com/kennethreitz/pipenv/blob/master/README.md"
output = "test_download.md"
pipenv.utils.download_file(url, output)
assert os.path.exists(output)
os.remove(output)
@@ -245,95 +261,140 @@ twine = "*"
"""
new_toml = pipenv.utils.cleanup_toml(toml)
# testing if the end of the generated file contains a newline
assert new_toml[-1] == '\n'
assert new_toml[-1] == "\n"
@pytest.mark.utils
@pytest.mark.parametrize(
'input_path, expected',
"input_path, expected",
[
(
'c:\\Program Files\\Python36\\python.exe',
'C:\\Program Files\\Python36\\python.exe',
"c:\\Program Files\\Python36\\python.exe",
"C:\\Program Files\\Python36\\python.exe",
),
(
'C:\\Program Files\\Python36\\python.exe',
'C:\\Program Files\\Python36\\python.exe',
"C:\\Program Files\\Python36\\python.exe",
"C:\\Program Files\\Python36\\python.exe",
),
('\\\\host\\share\\file.zip', '\\\\host\\share\\file.zip'),
('artifacts\\file.zip', 'artifacts\\file.zip'),
('.\\artifacts\\file.zip', '.\\artifacts\\file.zip'),
('..\\otherproject\\file.zip', '..\\otherproject\\file.zip'),
("\\\\host\\share\\file.zip", "\\\\host\\share\\file.zip"),
("artifacts\\file.zip", "artifacts\\file.zip"),
(".\\artifacts\\file.zip", ".\\artifacts\\file.zip"),
("..\\otherproject\\file.zip", "..\\otherproject\\file.zip"),
],
)
@pytest.mark.skipif(os.name != 'nt', reason='Windows file paths tested')
@pytest.mark.skipif(os.name != "nt", reason="Windows file paths tested")
def test_win_normalize_drive(self, input_path, expected):
assert pipenv.utils.normalize_drive(input_path) == expected
@pytest.mark.utils
@pytest.mark.parametrize(
'input_path, expected',
"input_path, expected",
[
('/usr/local/bin/python', '/usr/local/bin/python'),
('artifacts/file.zip', 'artifacts/file.zip'),
('./artifacts/file.zip', './artifacts/file.zip'),
('../otherproject/file.zip', '../otherproject/file.zip'),
("/usr/local/bin/python", "/usr/local/bin/python"),
("artifacts/file.zip", "artifacts/file.zip"),
("./artifacts/file.zip", "./artifacts/file.zip"),
("../otherproject/file.zip", "../otherproject/file.zip"),
],
)
@pytest.mark.skipif(os.name == 'nt', reason='*nix file paths tested')
@pytest.mark.skipif(os.name == "nt", reason="*nix file paths tested")
def test_nix_normalize_drive(self, input_path, expected):
assert pipenv.utils.normalize_drive(input_path) == expected
@pytest.mark.utils
@pytest.mark.parametrize(
'sources, expected_args',
"sources, expected_args",
[
([{'url': 'https://test.example.com/simple', 'verify_ssl': True}],
['-i', 'https://test.example.com/simple']),
([{'url': 'https://test.example.com/simple', 'verify_ssl': False}],
['-i', 'https://test.example.com/simple', '--trusted-host', 'test.example.com']),
([{'url': "https://pypi.org/simple"},
{'url': "https://custom.example.com/simple"}],
['-i', 'https://pypi.org/simple',
'--extra-index-url', 'https://custom.example.com/simple']),
([{'url': "https://pypi.org/simple"},
{'url': "https://custom.example.com/simple", 'verify_ssl': False}],
['-i', 'https://pypi.org/simple',
'--extra-index-url', 'https://custom.example.com/simple',
'--trusted-host', 'custom.example.com']),
([{'url': "https://pypi.org/simple"},
{'url': "https://user:password@custom.example.com/simple", 'verify_ssl': False}],
['-i', 'https://pypi.org/simple',
'--extra-index-url', 'https://user:password@custom.example.com/simple',
'--trusted-host', 'custom.example.com']),
([{'url': "https://pypi.org/simple"},
{'url': "https://user:password@custom.example.com/simple",}],
['-i', 'https://pypi.org/simple',
'--extra-index-url', 'https://user:password@custom.example.com/simple',]),
(
[{"url": "https://test.example.com/simple", "verify_ssl": True}],
["-i", "https://test.example.com/simple"],
),
(
[{"url": "https://test.example.com/simple", "verify_ssl": False}],
[
"-i",
"https://test.example.com/simple",
"--trusted-host",
"test.example.com",
],
),
(
[
{"url": "https://pypi.org/simple"},
{"url": "https://custom.example.com/simple"},
],
[
"-i",
"https://pypi.org/simple",
"--extra-index-url",
"https://custom.example.com/simple",
],
),
(
[
{"url": "https://pypi.org/simple"},
{"url": "https://custom.example.com/simple", "verify_ssl": False},
],
[
"-i",
"https://pypi.org/simple",
"--extra-index-url",
"https://custom.example.com/simple",
"--trusted-host",
"custom.example.com",
],
),
(
[
{"url": "https://pypi.org/simple"},
{
"url": "https://user:password@custom.example.com/simple",
"verify_ssl": False,
},
],
[
"-i",
"https://pypi.org/simple",
"--extra-index-url",
"https://user:password@custom.example.com/simple",
"--trusted-host",
"custom.example.com",
],
),
(
[
{"url": "https://pypi.org/simple"},
{"url": "https://user:password@custom.example.com/simple"},
],
[
"-i",
"https://pypi.org/simple",
"--extra-index-url",
"https://user:password@custom.example.com/simple",
],
),
],
)
def test_prepare_pip_source_args(self, sources, expected_args):
assert pipenv.utils.prepare_pip_source_args(sources, pip_args=None) == expected_args
assert (
pipenv.utils.prepare_pip_source_args(sources, pip_args=None)
== expected_args
)
@pytest.mark.utils
def test_parse_python_version(self):
ver = pipenv.utils.parse_python_version('Python 3.6.5\n')
assert ver == {'major': '3', 'minor': '6', 'micro': '5'}
ver = pipenv.utils.parse_python_version("Python 3.6.5\n")
assert ver == {"major": "3", "minor": "6", "micro": "5"}
@pytest.mark.utils
def test_parse_python_version_suffix(self):
ver = pipenv.utils.parse_python_version('Python 3.6.5rc1\n')
assert ver == {'major': '3', 'minor': '6', 'micro': '5'}
ver = pipenv.utils.parse_python_version("Python 3.6.5rc1\n")
assert ver == {"major": "3", "minor": "6", "micro": "5"}
@pytest.mark.utils
def test_parse_python_version_270(self):
ver = pipenv.utils.parse_python_version('Python 2.7\n')
assert ver == {'major': '2', 'minor': '7', 'micro': '0'}
ver = pipenv.utils.parse_python_version("Python 2.7\n")
assert ver == {"major": "2", "minor": "7", "micro": "0"}
@pytest.mark.utils
def test_parse_python_version_270_garbage(self):
ver = pipenv.utils.parse_python_version('Python 2.7+\n')
assert ver == {'major': '2', 'minor': '7', 'micro': '0'}
ver = pipenv.utils.parse_python_version("Python 2.7+\n")
assert ver == {"major": "2", "minor": "7", "micro": "0"}