mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Update tests to resolve some transient resolution issues
Signed-off-by: Dan Ryan <dan@danryan.co> probably need to sync submodules for this to work Signed-off-by: Dan Ryan <dan@danryan.co> Update to new version of artifacts Signed-off-by: Dan Ryan <dan@danryan.co> Fix windows failure Signed-off-by: Dan Ryan <dan@danryan.co> Update azure-pipelines.yml for Azure Pipelines Update lockfile test for windows Signed-off-by: Dan Ryan <dan@danryan.co> Fix scandir test Signed-off-by: Dan Ryan <dan@danryan.co> Update azure test steps Signed-off-by: Dan Ryan <dan@danryan.co> Fix virtualenv test Signed-off-by: Dan Ryan <dan@danryan.co> Fix python discovery when nothing is supplied Signed-off-by: Dan Ryan <dan@danryan.co> Fix cli ensure_project call Signed-off-by: Dan Ryan <dan@danryan.co> Fix run in virtualenv test Signed-off-by: Dan Ryan <dan@danryan.co> Show why virtualenv test failed if it did Signed-off-by: Dan Ryan <dan@danryan.co> Fix python interpreter discovery Signed-off-by: Dan Ryan <dan@danryan.co> scale down lock test modifications and increase error logging Signed-off-by: Dan Ryan <dan@danryan.co> Fix spinner bugs on windows and python discovery Signed-off-by: Dan Ryan <dan@danryan.co> Fix pythonfinder search algorithm to dodge false paths on win Signed-off-by: Dan Ryan <dan@danryan.co> use pipenv directly Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
@@ -1,4 +1,22 @@
|
||||
steps:
|
||||
- task: UsePythonVersion@0
|
||||
inputs:
|
||||
versionSpec: $(python.version)
|
||||
architecture: '$(python.architecture)'
|
||||
addToPath: true
|
||||
displayName: Use Python $(python.version)
|
||||
|
||||
- template: install-dependencies.yml
|
||||
|
||||
- script: |
|
||||
echo '##vso[task.setvariable variable=PIPENV_DEFAULT_PYTHON_VERSION]'$(python.version)
|
||||
env:
|
||||
PYTHON_VERSION: $(python.version)
|
||||
|
||||
- template: create-virtualenv.yml
|
||||
parameters:
|
||||
python_version: $(python.version)
|
||||
|
||||
- script: |
|
||||
python -m pip install --upgrade wheel pip setuptools twine readme_renderer[md]
|
||||
python setup.py sdist bdist_wheel
|
||||
|
||||
@@ -34,6 +34,8 @@ steps:
|
||||
echo "GIT_SSL_CAINFO: $(GIT_SSL_CAINFO)"
|
||||
echo "PIPENV PYTHON VERSION: $(python.version)"
|
||||
echo "python_version: ${{ parameters.python_version }}"
|
||||
git submodule sync
|
||||
git submodule update --init --recursive
|
||||
$(PY_EXE) -m pipenv install --deploy --dev --python="$(PY_EXE)"
|
||||
env:
|
||||
PIPENV_DEFAULT_PYTHON_VERSION: ${{ parameters.python_version }}
|
||||
|
||||
@@ -4,15 +4,11 @@ parameters:
|
||||
steps:
|
||||
- script: |
|
||||
# Fix Git SSL errors
|
||||
echo "Using pipenv python version: $PIPENV_DEFAULT_PYTHON_VERSION"
|
||||
echo "Using pipenv python version: $(PIPENV_DEFAULT_PYTHON_VERSION)"
|
||||
git submodule sync && git submodule update --init --recursive
|
||||
pipenv run pytest --junitxml=test-results.xml
|
||||
displayName: Run integration tests
|
||||
env:
|
||||
PY_EXE: $(PY_EXE)
|
||||
GIT_SSL_CAINFO: $(GIT_SSL_CAINFO)
|
||||
LANG: $(LANG)
|
||||
PIP_PROCESS_DEPENDENCY_LINKS: '$(PIP_PROCESS_DEPENDENCY_LINKS)'
|
||||
PIPENV_DEFAULT_PYTHON_VERSION: '${{ parameters.python_version }}'
|
||||
PYTHONWARNINGS: ignore:DEPRECATION
|
||||
PIPENV_NOSPIN: '1'
|
||||
PIPENV_DEFAULT_PYTHON_VERSION: ${{ parameters.python_version }}
|
||||
|
||||
@@ -6,14 +6,16 @@ steps:
|
||||
subst T: "$env:TEMP"
|
||||
Write-Host "##vso[task.setvariable variable=TEMP]T:\"
|
||||
Write-Host "##vso[task.setvariable variable=TMP]T:\"
|
||||
Write-Host "##vso[task.setvariable variable=PIPENV_DEFAULT_PYTHON_VERSION]$env:PYTHON_VERSION"
|
||||
Write-Host "##vso[task.setvariable variable=PIPENV_NOSPIN]1"
|
||||
displayName: Fix Temp Variable
|
||||
env:
|
||||
PYTHON_VERSION: ${{ parameters.python_version }}
|
||||
|
||||
- script: |
|
||||
echo "Using pipenv python version: $PIPENV_DEFAULT_PYTHON_VERSION"
|
||||
git submodule sync && git submodule update --init --recursive
|
||||
pipenv run pytest -ra --ignore=pipenv\patched --ignore=pipenv\vendor --junitxml=test-results.xml tests
|
||||
displayName: Run integration tests
|
||||
env:
|
||||
PIPENV_DEFAULT_PYTHON_VERSION: '${{ parameters.python_version }}'
|
||||
PYTHONWARNINGS: 'ignore:DEPRECATION'
|
||||
PIPENV_NOSPIN: '1'
|
||||
|
||||
@@ -2,6 +2,24 @@ parameters:
|
||||
python_version: ''
|
||||
|
||||
steps:
|
||||
- task: UsePythonVersion@0
|
||||
inputs:
|
||||
versionSpec: $(python.version)
|
||||
architecture: '$(python.architecture)'
|
||||
addToPath: true
|
||||
displayName: Use Python $(python.version)
|
||||
|
||||
- template: install-dependencies.yml
|
||||
|
||||
- script: |
|
||||
echo '##vso[task.setvariable variable=PIPENV_DEFAULT_PYTHON_VERSION]'$(python.version)
|
||||
env:
|
||||
PYTHON_VERSION: $(python.version)
|
||||
|
||||
- template: create-virtualenv.yml
|
||||
parameters:
|
||||
python_version: $(python.version)
|
||||
|
||||
- script: |
|
||||
python -m pip install --upgrade invoke requests parver bs4 vistir towncrier pip setuptools wheel --upgrade-strategy=eager
|
||||
python -m invoke vendoring.update
|
||||
|
||||
+25
-6
@@ -18,6 +18,9 @@ trigger:
|
||||
- .gitattributes
|
||||
- .editorconfig
|
||||
|
||||
variables:
|
||||
- group: CI
|
||||
|
||||
jobs:
|
||||
- job: TestLinux
|
||||
pool:
|
||||
@@ -38,12 +41,28 @@ jobs:
|
||||
- template: .azure-pipelines/steps/run-tests.yml
|
||||
parameters:
|
||||
vmImage: 'Ubuntu-16.04'
|
||||
- template: .azure-pipelines/steps/run-vendor-scripts.yml
|
||||
parameters:
|
||||
vmImage: 'Ubuntu-16.04'
|
||||
- template: .azure-pipelines/steps/build-package.yml
|
||||
parameters:
|
||||
vmImage: 'Ubuntu-16.04'
|
||||
|
||||
- job: TestVendoring
|
||||
pool:
|
||||
vmImage: 'Ubuntu-16.04'
|
||||
variables:
|
||||
python.version: '3.7.2'
|
||||
python.architecture: x64
|
||||
steps:
|
||||
- template: .azure-pipelines/steps/run-vendor-scripts.yml
|
||||
parameters:
|
||||
vmImage: 'Ubuntu-16.04'
|
||||
|
||||
- job: TestPackaging
|
||||
pool:
|
||||
vmImage: 'Ubuntu-16.04'
|
||||
variables:
|
||||
python.version: '3.7.2'
|
||||
python.architecture: x64
|
||||
steps:
|
||||
- template: .azure-pipelines/steps/build-package.yml
|
||||
parameters:
|
||||
vmImage: 'Ubuntu-16.04'
|
||||
|
||||
- job: TestWindows
|
||||
pool:
|
||||
|
||||
@@ -316,7 +316,10 @@ def lock(
|
||||
from ..core import ensure_project, do_init, do_lock
|
||||
|
||||
# Ensure that virtualenv is available.
|
||||
ensure_project(three=state.three, python=state.python, pypi_mirror=state.pypi_mirror)
|
||||
ensure_project(
|
||||
three=state.three, python=state.python, pypi_mirror=state.pypi_mirror,
|
||||
warn=(not state.quiet)
|
||||
)
|
||||
if state.installstate.requirementstxt:
|
||||
do_init(
|
||||
dev=state.installstate.dev,
|
||||
@@ -330,6 +333,7 @@ def lock(
|
||||
pre=state.installstate.pre,
|
||||
keep_outdated=state.installstate.keep_outdated,
|
||||
pypi_mirror=state.pypi_mirror,
|
||||
write=not state.quiet,
|
||||
)
|
||||
|
||||
|
||||
|
||||
+31
-4
@@ -6,7 +6,7 @@ import os
|
||||
import click.types
|
||||
|
||||
from click import (
|
||||
BadParameter, Group, Option, argument, echo, make_pass_decorator, option
|
||||
BadParameter, BadArgumentUsage, Group, Option, argument, echo, make_pass_decorator, option
|
||||
)
|
||||
from click_didyoumean import DYMMixin
|
||||
|
||||
@@ -56,6 +56,7 @@ class State(object):
|
||||
self.index = None
|
||||
self.extra_index_urls = []
|
||||
self.verbose = False
|
||||
self.quiet = False
|
||||
self.pypi_mirror = None
|
||||
self.python = None
|
||||
self.two = None
|
||||
@@ -231,12 +232,32 @@ def verbose_option(f):
|
||||
def callback(ctx, param, value):
|
||||
state = ctx.ensure_object(State)
|
||||
if value:
|
||||
if state.quiet:
|
||||
raise BadArgumentUsage(
|
||||
"--verbose and --quiet are mutually exclusive! Please choose one!",
|
||||
ctx=ctx
|
||||
)
|
||||
state.verbose = True
|
||||
setup_verbosity(ctx, param, value)
|
||||
setup_verbosity(ctx, param, 1)
|
||||
return option("--verbose", "-v", is_flag=True, expose_value=False,
|
||||
callback=callback, help="Verbose mode.", type=click.types.BOOL)(f)
|
||||
|
||||
|
||||
def quiet_option(f):
|
||||
def callback(ctx, param, value):
|
||||
state = ctx.ensure_object(State)
|
||||
if value:
|
||||
if state.verbose:
|
||||
raise BadArgumentUsage(
|
||||
"--verbose and --quiet are mutually exclusive! Please choose one!",
|
||||
ctx=ctx
|
||||
)
|
||||
state.quiet = True
|
||||
setup_verbosity(ctx, param, -1)
|
||||
return option("--quiet", "-q", is_flag=True, expose_value=False,
|
||||
callback=callback, help="Quiet mode.", type=click.types.BOOL)(f)
|
||||
|
||||
|
||||
def site_packages_option(f):
|
||||
def callback(ctx, param, value):
|
||||
state = ctx.ensure_object(State)
|
||||
@@ -313,8 +334,14 @@ def setup_verbosity(ctx, param, value):
|
||||
if not value:
|
||||
return
|
||||
import logging
|
||||
logging.getLogger("pip").setLevel(logging.INFO)
|
||||
environments.PIPENV_VERBOSITY = 1
|
||||
loggers = ("pip", "piptools")
|
||||
if value == 1:
|
||||
for logger in loggers:
|
||||
logging.getLogger(logger).setLevel(logging.INFO)
|
||||
elif value == -1:
|
||||
for logger in loggers:
|
||||
logging.getLogger(logger).setLevel(logging.CRITICAL)
|
||||
environments.PIPENV_VERBOSITY = value
|
||||
|
||||
|
||||
def validate_python_path(ctx, param, value):
|
||||
|
||||
+18
-15
@@ -35,7 +35,7 @@ from .utils import (
|
||||
get_canonical_names, is_pinned, is_pypi_url, is_required_version, is_star,
|
||||
is_valid_url, parse_indexes, pep423_name, prepare_pip_source_args,
|
||||
proper_case, python_version, venv_resolve_deps, run_command,
|
||||
is_python_command, find_python
|
||||
is_python_command, find_python, make_posix, interrupt_handled_subprocess
|
||||
)
|
||||
|
||||
|
||||
@@ -371,6 +371,9 @@ def ensure_python(three=None, python=None):
|
||||
if not python:
|
||||
python = PIPENV_DEFAULT_PYTHON_VERSION
|
||||
path_to_python = find_a_system_python(python)
|
||||
if environments.is_verbose():
|
||||
click.echo(u"Using python: {0}".format(python), err=True)
|
||||
click.echo(u"Path to python: {0}".format(path_to_python), err=True)
|
||||
if not path_to_python and python is not None:
|
||||
# We need to install Python.
|
||||
click.echo(
|
||||
@@ -885,11 +888,13 @@ def do_create_virtualenv(python=None, site_packages=False, pypi_mirror=None):
|
||||
)
|
||||
|
||||
# Default to using sys.executable, if Python wasn't provided.
|
||||
using_string = u"Using"
|
||||
if not python:
|
||||
python = sys.executable
|
||||
using_string = "Using default python from"
|
||||
click.echo(
|
||||
u"{0} {1} {3} {2}".format(
|
||||
crayons.normal("Using", bold=True),
|
||||
crayons.normal(using_string, bold=True),
|
||||
crayons.red(python, bold=True),
|
||||
crayons.normal(fix_utf8("to create virtualenv…"), bold=True),
|
||||
crayons.green("({0})".format(python_version(python))),
|
||||
@@ -919,21 +924,19 @@ def do_create_virtualenv(python=None, site_packages=False, pypi_mirror=None):
|
||||
pip_config = {}
|
||||
|
||||
# Actually create the virtualenv.
|
||||
error = None
|
||||
with create_spinner(u"Creating virtual environment...") as sp:
|
||||
c = vistir.misc.run(
|
||||
cmd, verbose=False, return_object=True, write_to_stdout=False,
|
||||
combine_stderr=False, block=True, nospin=True, env=pip_config,
|
||||
with interrupt_handled_subprocess(cmd, combine_stderr=False, env=pip_config) as c:
|
||||
click.echo(crayons.blue(u"{0}".format(c.out)), err=True)
|
||||
if c.returncode != 0:
|
||||
error = c.err if environments.is_verbose() else exceptions.prettify_exc(c.err)
|
||||
sp.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format(u"Failed creating virtual environment"))
|
||||
else:
|
||||
sp.green.ok(environments.PIPENV_SPINNER_OK_TEXT.format(u"Successfully created virtual environment!"))
|
||||
if error is not None:
|
||||
raise exceptions.VirtualenvCreationException(
|
||||
extra=crayons.red("{0}".format(error))
|
||||
)
|
||||
click.echo(crayons.blue(u"{0}".format(c.out)), err=True)
|
||||
if c.returncode != 0:
|
||||
sp.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format(u"Failed creating virtual environment"))
|
||||
error = c.err if environments.is_verbose() else exceptions.prettify_exc(c.err)
|
||||
raise exceptions.VirtualenvCreationException(
|
||||
extra=crayons.red("{0}".format(error))
|
||||
)
|
||||
else:
|
||||
|
||||
sp.green.ok(environments.PIPENV_SPINNER_OK_TEXT.format(u"Successfully created virtual environment!"))
|
||||
|
||||
# Associate project directory with the environment.
|
||||
# This mimics Pew's "setproject".
|
||||
|
||||
@@ -126,7 +126,7 @@ PIPENV_MAX_ROUNDS = int(os.environ.get("PIPENV_MAX_ROUNDS", "16"))
|
||||
Default is 16, an arbitrary number that works most of the time.
|
||||
"""
|
||||
|
||||
PIPENV_MAX_SUBPROCESS = int(os.environ.get("PIPENV_MAX_SUBPROCESS", "16"))
|
||||
PIPENV_MAX_SUBPROCESS = int(os.environ.get("PIPENV_MAX_SUBPROCESS", "8"))
|
||||
"""How many subprocesses should Pipenv use when installing.
|
||||
|
||||
Default is 16, an arbitrary number that seems to work.
|
||||
@@ -150,14 +150,12 @@ environments.
|
||||
if PIPENV_IS_CI:
|
||||
PIPENV_NOSPIN = True
|
||||
|
||||
PIPENV_SPINNER = "dots"
|
||||
PIPENV_SPINNER = "dots" if not os.name == "nt" else "bouncingBar"
|
||||
"""Sets the default spinner type.
|
||||
|
||||
Spinners are identitcal to the node.js spinners and can be found at
|
||||
https://github.com/sindresorhus/cli-spinners
|
||||
"""
|
||||
if os.name == "nt":
|
||||
PIPENV_SPINNER = "bouncingBar"
|
||||
|
||||
PIPENV_PIPFILE = os.environ.get("PIPENV_PIPFILE")
|
||||
"""If set, this specifies a custom Pipfile location.
|
||||
|
||||
+42
-4
@@ -6,6 +6,7 @@ import logging
|
||||
import os
|
||||
import posixpath
|
||||
import re
|
||||
import signal
|
||||
import shutil
|
||||
import stat
|
||||
import sys
|
||||
@@ -25,7 +26,7 @@ six.add_move(six.MovedAttribute("Set", "collections", "collections.abc")) # noq
|
||||
from six.moves import Mapping, Sequence, Set
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from .vendor.vistir.compat import ResourceWarning, lru_cache
|
||||
from .vendor.vistir.misc import fs_str
|
||||
from .vendor.vistir.misc import fs_str, run
|
||||
|
||||
import crayons
|
||||
import parse
|
||||
@@ -964,9 +965,9 @@ def create_spinner(text, nospin=None, spinner_name=None):
|
||||
if nospin is None:
|
||||
nospin = environments.PIPENV_NOSPIN
|
||||
with spin.create_spinner(
|
||||
spinner_name=spinner_name,
|
||||
start_text=fs_str(text),
|
||||
nospin=nospin, write_to_stdout=False
|
||||
spinner_name=spinner_name,
|
||||
start_text=fs_str(text),
|
||||
nospin=nospin, write_to_stdout=False
|
||||
) as sp:
|
||||
yield sp
|
||||
|
||||
@@ -2103,3 +2104,40 @@ def make_marker_from_specifier(spec):
|
||||
specset = cleanup_pyspecs(SpecifierSet(spec))
|
||||
marker_str = " and ".join([format_pyversion(pv) for pv in specset])
|
||||
return Marker(marker_str)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def interrupt_handled_subprocess(
|
||||
cmd, verbose=False, return_object=True, write_to_stdout=False, combine_stderr=True,
|
||||
block=True, nospin=True, env=None
|
||||
):
|
||||
"""Given a :class:`subprocess.Popen` instance, wrap it in exception handlers.
|
||||
|
||||
Terminates the subprocess when and if a `SystemExit` or `KeyboardInterrupt` are
|
||||
processed.
|
||||
|
||||
Arguments:
|
||||
:param str cmd: A command to run
|
||||
:param bool verbose: Whether to run with verbose mode enabled, default False
|
||||
:param bool return_object: Whether to return a subprocess instance or a 2-tuple, default True
|
||||
:param bool write_to_stdout: Whether to write directly to stdout, default False
|
||||
:param bool combine_stderr: Whether to combine stdout and stderr, default True
|
||||
:param bool block: Whether the subprocess should be a blocking subprocess, default True
|
||||
:param bool nospin: Whether to suppress the spinner with the subprocess, default True
|
||||
:param Optional[Dict[str, str]] env: A dictionary to merge into the subprocess environment
|
||||
:return: A subprocess, wrapped in exception handlers, as a context manager
|
||||
:rtype: :class:`subprocess.Popen` obj: An instance of a running subprocess
|
||||
"""
|
||||
obj = run(
|
||||
cmd, verbose=verbose, return_object=True, write_to_stdout=False,
|
||||
combine_stderr=False, block=True, nospin=True, env=env,
|
||||
)
|
||||
try:
|
||||
yield obj
|
||||
except (SystemExit, KeyboardInterrupt):
|
||||
if os.name == "nt":
|
||||
os.kill(obj.pid, signal.CTRL_BREAK_EVENT)
|
||||
else:
|
||||
os.kill(obj.pid, signal.SIGINT)
|
||||
obj.wait()
|
||||
raise
|
||||
|
||||
Vendored
+1
-1
@@ -62,7 +62,7 @@ KNOWN_EXTS = {"exe", "py", "fish", "sh", ""}
|
||||
KNOWN_EXTS = KNOWN_EXTS | set(
|
||||
filter(None, os.environ.get("PATHEXT", "").split(os.pathsep))
|
||||
)
|
||||
PY_MATCH_STR = r"((?P<implementation>{0})(?:\d?(?:\.\d[cpm]{{0,3}}))?(?:-?[\d\.]+)*[^z])".format(
|
||||
PY_MATCH_STR = r"((?P<implementation>{0})(?:\d?(?:\.\d[cpm]{{0,3}}))?(?:-?[\d\.]+)*[^zw])".format(
|
||||
"|".join(PYTHON_IMPLEMENTATIONS)
|
||||
)
|
||||
EXE_MATCH_STR = r"{0}(?:\.(?P<ext>{1}))?".format(PY_MATCH_STR, "|".join(KNOWN_EXTS))
|
||||
|
||||
Vendored
+3
-1
@@ -6,6 +6,7 @@ import json
|
||||
import locale
|
||||
import logging
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
from collections import OrderedDict
|
||||
@@ -303,9 +304,10 @@ def _create_subprocess(
|
||||
else:
|
||||
try:
|
||||
c.out, c.err = c.communicate()
|
||||
except (SystemExit, TimeoutError):
|
||||
except (SystemExit, KeyboardInterrupt, TimeoutError):
|
||||
c.terminate()
|
||||
c.out, c.err = c.communicate()
|
||||
raise
|
||||
if not block:
|
||||
c.wait()
|
||||
c.out = to_text("{0}".format(c.out)) if c.out else fs_str("")
|
||||
|
||||
Vendored
-2
@@ -41,7 +41,6 @@ if os.name == "nt": # pragma: no cover
|
||||
"""
|
||||
spinner.fail()
|
||||
spinner.stop()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
else: # pragma: no cover
|
||||
@@ -55,7 +54,6 @@ else: # pragma: no cover
|
||||
"""
|
||||
spinner.red.fail("✘")
|
||||
spinner.stop()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
CLEAR_LINE = chr(27) + "[K"
|
||||
|
||||
@@ -17,6 +17,7 @@ from vistir.contextmanagers import temp_environ
|
||||
from vistir.path import mkdir_p, create_tracked_tempdir, handle_remove_readonly
|
||||
|
||||
from pipenv._compat import Path
|
||||
from pipenv.cmdparse import Script
|
||||
from pipenv.exceptions import VirtualenvActivationException
|
||||
from pipenv.vendor import delegator, requests, toml, tomlkit
|
||||
from pytest_pypi.app import prepare_fixtures
|
||||
@@ -111,6 +112,8 @@ def pytest_runtest_setup(item):
|
||||
sys.version_info < (3, 0)
|
||||
):
|
||||
pytest.skip('test only runs on python 3')
|
||||
if item.get_closest_marker('skip_osx') is not None and sys.platform == 'darwin':
|
||||
pytest.skip('test does not apply on OSX')
|
||||
if item.get_closest_marker('lte_py36') is not None and (
|
||||
sys.version_info >= (3, 7)
|
||||
):
|
||||
@@ -329,8 +332,10 @@ class _PipenvInstance(object):
|
||||
|
||||
with TemporaryDirectory(prefix='pipenv-', suffix='-cache') as tempdir:
|
||||
os.environ['PIPENV_CACHE_DIR'] = fs_str(tempdir.name)
|
||||
c = delegator.run('pipenv {0}'.format(cmd), block=block,
|
||||
cwd=os.path.abspath(self.path))
|
||||
c = delegator.run(
|
||||
'pipenv {0}'.format(cmd), block=block,
|
||||
cwd=os.path.abspath(self.path), env=os.environ.copy()
|
||||
)
|
||||
if 'PIPENV_CACHE_DIR' in os.environ:
|
||||
del os.environ['PIPENV_CACHE_DIR']
|
||||
|
||||
|
||||
@@ -217,6 +217,7 @@ def test_install_parse_error(PipenvInstance, pypi):
|
||||
@pytest.mark.code
|
||||
@pytest.mark.check
|
||||
@pytest.mark.unused
|
||||
@pytest.mark.skip_osx
|
||||
@pytest.mark.needs_internet(reason='required by check')
|
||||
def test_check_unused(PipenvInstance, pypi):
|
||||
with PipenvInstance(chdir=True, pypi=pypi) as p:
|
||||
|
||||
@@ -70,12 +70,12 @@ def test_venv_file(venv_name, PipenvInstance, pypi):
|
||||
venv_loc = Path(c.out.strip()).absolute()
|
||||
assert venv_loc.exists()
|
||||
assert venv_loc.joinpath('.project').exists()
|
||||
venv_path = venv_loc.as_posix()
|
||||
venv_path = normalize_drive(venv_loc.as_posix())
|
||||
if os.path.sep in venv_name:
|
||||
venv_expected_path = Path(p.path).joinpath(venv_name).absolute().as_posix()
|
||||
else:
|
||||
venv_expected_path = Path(workon_home.name).joinpath(venv_name).absolute().as_posix()
|
||||
assert venv_path == venv_expected_path
|
||||
assert venv_path == normalize_drive(venv_expected_path)
|
||||
|
||||
|
||||
@pytest.mark.dotvenv
|
||||
|
||||
@@ -28,8 +28,9 @@ def test_basic_setup(PipenvInstance, pypi):
|
||||
assert "certifi" in p.lockfile["default"]
|
||||
|
||||
|
||||
@pytest.mark.install
|
||||
@flaky
|
||||
@pytest.mark.install
|
||||
@pytest.mark.skip_osx
|
||||
def test_basic_install(PipenvInstance, pypi):
|
||||
with PipenvInstance(pypi=pypi) as p:
|
||||
c = p.pipenv("install requests")
|
||||
@@ -42,8 +43,8 @@ def test_basic_install(PipenvInstance, pypi):
|
||||
assert "certifi" in p.lockfile["default"]
|
||||
|
||||
|
||||
@pytest.mark.install
|
||||
@flaky
|
||||
@pytest.mark.install
|
||||
def test_mirror_install(PipenvInstance, pypi):
|
||||
with temp_environ(), PipenvInstance(chdir=True, pypi=pypi) as p:
|
||||
mirror_url = os.environ.pop(
|
||||
@@ -68,9 +69,9 @@ def test_mirror_install(PipenvInstance, pypi):
|
||||
assert "certifi" in p.lockfile["default"]
|
||||
|
||||
|
||||
@flaky
|
||||
@pytest.mark.install
|
||||
@pytest.mark.needs_internet
|
||||
@flaky
|
||||
def test_bad_mirror_install(PipenvInstance, pypi):
|
||||
with temp_environ(), PipenvInstance(chdir=True) as p:
|
||||
# This demonstrates that the mirror parameter is being used
|
||||
@@ -79,8 +80,8 @@ def test_bad_mirror_install(PipenvInstance, pypi):
|
||||
assert c.return_code != 0
|
||||
|
||||
|
||||
@pytest.mark.complex
|
||||
@pytest.mark.lock
|
||||
@pytest.mark.complex
|
||||
@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:
|
||||
@@ -91,9 +92,9 @@ def test_complex_lock(PipenvInstance, pypi):
|
||||
assert "futures" in p.lockfile[u"default"]
|
||||
|
||||
|
||||
@flaky
|
||||
@pytest.mark.dev
|
||||
@pytest.mark.run
|
||||
@flaky
|
||||
def test_basic_dev_install(PipenvInstance, pypi):
|
||||
with PipenvInstance(pypi=pypi) as p:
|
||||
c = p.pipenv("install requests --dev")
|
||||
@@ -109,9 +110,9 @@ def test_basic_dev_install(PipenvInstance, pypi):
|
||||
assert c.return_code == 0
|
||||
|
||||
|
||||
@flaky
|
||||
@pytest.mark.dev
|
||||
@pytest.mark.install
|
||||
@flaky
|
||||
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:
|
||||
@@ -136,8 +137,8 @@ pytz = "*"
|
||||
assert c.return_code == 0
|
||||
|
||||
|
||||
@pytest.mark.install
|
||||
@flaky
|
||||
@pytest.mark.install
|
||||
def test_install_without_dev_section(PipenvInstance, pypi):
|
||||
with PipenvInstance(pypi=pypi) as p:
|
||||
with open(p.pipfile_path, "w") as f:
|
||||
@@ -156,9 +157,9 @@ six = "*"
|
||||
assert c.return_code == 0
|
||||
|
||||
|
||||
@flaky
|
||||
@pytest.mark.extras
|
||||
@pytest.mark.install
|
||||
@flaky
|
||||
def test_extras_install(PipenvInstance, pypi):
|
||||
with PipenvInstance(pypi=pypi, chdir=True) as p:
|
||||
c = p.pipenv("install requests[socks]")
|
||||
@@ -173,9 +174,9 @@ def test_extras_install(PipenvInstance, pypi):
|
||||
assert "pysocks" in p.lockfile["default"]
|
||||
|
||||
|
||||
@pytest.mark.install
|
||||
@pytest.mark.pin
|
||||
@flaky
|
||||
@pytest.mark.pin
|
||||
@pytest.mark.install
|
||||
def test_windows_pinned_pipfile(PipenvInstance, pypi):
|
||||
with PipenvInstance(pypi=pypi) as p:
|
||||
with open(p.pipfile_path, "w") as f:
|
||||
@@ -190,10 +191,10 @@ requests = "==2.19.1"
|
||||
assert "requests" in p.lockfile["default"]
|
||||
|
||||
|
||||
@flaky
|
||||
@pytest.mark.install
|
||||
@pytest.mark.resolver
|
||||
@pytest.mark.backup_resolver
|
||||
@flaky
|
||||
def test_backup_resolver(PipenvInstance, pypi):
|
||||
with PipenvInstance(pypi=pypi) as p:
|
||||
with open(p.pipfile_path, "w") as f:
|
||||
@@ -208,9 +209,9 @@ def test_backup_resolver(PipenvInstance, pypi):
|
||||
assert "ibm-db-sa-py3" in p.lockfile["default"]
|
||||
|
||||
|
||||
@flaky
|
||||
@pytest.mark.run
|
||||
@pytest.mark.alt
|
||||
@flaky
|
||||
def test_alternative_version_specifier(PipenvInstance, pypi):
|
||||
with PipenvInstance(pypi=pypi) as p:
|
||||
with open(p.pipfile_path, "w") as f:
|
||||
@@ -233,9 +234,9 @@ requests = {version = "*"}
|
||||
assert c.return_code == 0
|
||||
|
||||
|
||||
@flaky
|
||||
@pytest.mark.run
|
||||
@pytest.mark.alt
|
||||
@flaky
|
||||
def test_outline_table_specifier(PipenvInstance, pypi):
|
||||
with PipenvInstance(pypi=pypi) as p:
|
||||
with open(p.pipfile_path, "w") as f:
|
||||
@@ -297,6 +298,7 @@ def test_requirements_to_pipfile(PipenvInstance, pypi):
|
||||
|
||||
|
||||
@pytest.mark.install
|
||||
@pytest.mark.skip_osx
|
||||
@pytest.mark.requirements
|
||||
def test_skip_requirements_when_pipfile(PipenvInstance, pypi):
|
||||
"""Ensure requirements.txt is NOT imported when
|
||||
|
||||
@@ -140,7 +140,7 @@ def test_resolver_unique_markers(PipenvInstance, pypi):
|
||||
This verifies that we clean that successfully.
|
||||
"""
|
||||
with PipenvInstance(chdir=True, pypi=pypi) as p:
|
||||
c = p.pipenv('install vcrpy==1.11.0')
|
||||
c = p.pipenv('install vcrpy==2.0.1')
|
||||
assert c.return_code == 0
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
@@ -148,7 +148,7 @@ def test_resolver_unique_markers(PipenvInstance, pypi):
|
||||
yarl = p.lockfile['default']['yarl']
|
||||
assert 'markers' in yarl
|
||||
# Two possible marker sets are ok here
|
||||
assert yarl['markers'] in ["python_version in '3.4, 3.5, 3.6'", "python_version >= '3.4.1'"]
|
||||
assert yarl['markers'] in ["python_version in '3.4, 3.5, 3.6'", "python_version >= '3.4'"]
|
||||
|
||||
|
||||
@pytest.mark.project
|
||||
|
||||
@@ -596,18 +596,20 @@ def test_lock_no_warnings(PipenvInstance, pypi):
|
||||
@pytest.mark.lock
|
||||
@pytest.mark.install
|
||||
@pytest.mark.skipif(sys.version_info >= (3, 5), reason="scandir doesn't get installed on python 3.5+")
|
||||
def test_lock_missing_cache_entries_gets_all_hashes(monkeypatch, PipenvInstance, pypi, tmpdir):
|
||||
def test_lock_missing_cache_entries_gets_all_hashes(PipenvInstance, pypi, tmpdir):
|
||||
"""
|
||||
Test locking pathlib2 on python2.7 which needs `scandir`, but fails to resolve when
|
||||
using a fresh dependency cache.
|
||||
"""
|
||||
|
||||
with monkeypatch.context() as m:
|
||||
monkeypatch.setattr("pipenv.patched.piptools.locations.CACHE_DIR", tmpdir.strpath)
|
||||
with temp_environ():
|
||||
os.environ["PIPENV_CACHE_DIR"] = str(tmpdir.strpath)
|
||||
with PipenvInstance(pypi=pypi, chdir=True) as p:
|
||||
p._pipfile.add("pathlib2", "*")
|
||||
assert "pathlib2" in p.pipfile["packages"]
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0, (c.err, ("\n".join(["{0}: {1}\n".format(k, v) for k, v in os.environ.items()])))
|
||||
c = p.pipenv("lock --clear")
|
||||
assert c.return_code == 0, c.err
|
||||
assert "pathlib2" in p.lockfile["default"]
|
||||
assert "scandir" in p.lockfile["default"]
|
||||
|
||||
@@ -10,6 +10,7 @@ from pipenv.patched import pipfile
|
||||
from pipenv.project import Project
|
||||
from pipenv.utils import temp_environ
|
||||
from pipenv.vendor.vistir.path import is_in_path
|
||||
from pipenv.vendor.delegator import run as delegator_run
|
||||
import pipenv.environments
|
||||
|
||||
|
||||
@@ -173,22 +174,38 @@ def test_include_editable_packages(PipenvInstance, pypi, testsroot, pathlib_tmpd
|
||||
@pytest.mark.virtualenv
|
||||
def test_run_in_virtualenv_with_global_context(PipenvInstance, pypi, virtualenv):
|
||||
with PipenvInstance(chdir=True, pypi=pypi, venv_root=virtualenv.as_posix(), ignore_virtualenvs=False, venv_in_project=False) as p:
|
||||
c = p.pipenv('run pip freeze')
|
||||
assert c.return_code == 0
|
||||
assert 'Creating a virtualenv' not in c.err
|
||||
c = delegator_run(
|
||||
"pipenv run pip freeze", cwd=os.path.abspath(p.path),
|
||||
env=os.environ.copy()
|
||||
)
|
||||
assert c.return_code == 0, (c.out, c.err)
|
||||
assert 'Creating a virtualenv' not in c.err, c.err
|
||||
project = Project()
|
||||
assert project.virtualenv_location == virtualenv.as_posix()
|
||||
c = p.pipenv("run pip install click")
|
||||
assert c.return_code == 0
|
||||
assert "Courtesy Notice" in c.err
|
||||
c = p.pipenv("install six")
|
||||
assert c.return_code == 0
|
||||
c = p.pipenv('run python -c "import click;print(click.__file__)"')
|
||||
assert c.return_code == 0
|
||||
assert is_in_path(c.out.strip(), str(virtualenv))
|
||||
c = p.pipenv("clean --dry-run")
|
||||
assert c.return_code == 0
|
||||
assert "click" in c.out
|
||||
assert project.virtualenv_location == virtualenv.as_posix(), (
|
||||
project.virtualenv_location, virtualenv.as_posix()
|
||||
)
|
||||
c = delegator_run(
|
||||
"pipenv run pip install click", cwd=os.path.abspath(p.path),
|
||||
env=os.environ.copy()
|
||||
)
|
||||
assert c.return_code == 0, (c.out, c.err)
|
||||
assert "Courtesy Notice" in c.err, (c.out, c.err)
|
||||
c = delegator_run(
|
||||
"pipenv install six", cwd=os.path.abspath(p.path), env=os.environ.copy()
|
||||
)
|
||||
assert c.return_code == 0, (c.out, c.err)
|
||||
c = delegator_run(
|
||||
'pipenv run python -c "import click;print(click.__file__)"',
|
||||
cwd=os.path.abspath(p.path), env=os.environ.copy()
|
||||
)
|
||||
assert c.return_code == 0, (c.out, c.err)
|
||||
assert is_in_path(c.out.strip(), str(virtualenv)), (c.out.strip(), str(virtualenv))
|
||||
c = delegator_run(
|
||||
"pipenv clean --dry-run", cwd=os.path.abspath(p.path),
|
||||
env=os.environ.copy()
|
||||
)
|
||||
assert c.return_code == 0, (c.out, c.err)
|
||||
assert "click" in c.out, c.out
|
||||
|
||||
|
||||
@pytest.mark.project
|
||||
|
||||
+1
-1
Submodule tests/pypi updated: 7f759bef45...f3260ec6bf
Reference in New Issue
Block a user