mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #2645 from pypa/bugfix/2527-pipenv-verbosity
PIPENV_VERBOSITY
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
Added environment variable `PIPENV_VERBOSITY` to control output verbosity
|
||||
without needing to pass options.
|
||||
+12
-3
@@ -1612,19 +1612,28 @@ def format_pip_output(out, r=None):
|
||||
|
||||
|
||||
def warn_in_virtualenv():
|
||||
from .environments import PIPENV_USE_SYSTEM, PIPENV_VIRTUALENV
|
||||
from .environments import (
|
||||
PIPENV_USE_SYSTEM,
|
||||
PIPENV_VIRTUALENV,
|
||||
PIPENV_VERBOSITY,
|
||||
)
|
||||
|
||||
# Only warn if pipenv isn't already active.
|
||||
pipenv_active = os.environ.get("PIPENV_ACTIVE")
|
||||
if (PIPENV_USE_SYSTEM or PIPENV_VIRTUALENV) and not pipenv_active:
|
||||
if (
|
||||
(PIPENV_USE_SYSTEM or PIPENV_VIRTUALENV)
|
||||
and not (pipenv_active or PIPENV_VERBOSITY < 0)
|
||||
):
|
||||
click.echo(
|
||||
"{0}: Pipenv found itself running within a virtual environment, "
|
||||
"so it will automatically use that environment, instead of "
|
||||
"creating its own for any project. You can set "
|
||||
"{1} to force pipenv to ignore that environment and create "
|
||||
"its own instead.".format(
|
||||
"its own instead. You can set {2} to suppress this "
|
||||
"warning.".format(
|
||||
crayons.green("Courtesy Notice"),
|
||||
crayons.normal("PIPENV_IGNORE_VIRTUALENVS=1", bold=True),
|
||||
crayons.normal("PIPENV_VERBOSITY=-1", bold=True),
|
||||
),
|
||||
err=True,
|
||||
)
|
||||
|
||||
@@ -174,6 +174,13 @@ PIPENV_VENV_IN_PROJECT = bool(os.environ.get("PIPENV_VENV_IN_PROJECT"))
|
||||
Default is to create new virtual environments in a global location.
|
||||
"""
|
||||
|
||||
PIPENV_VERBOSITY = int(os.environ.get("PIPENV_VERBOSITY", 0))
|
||||
"""Verbosity setting for pipenv.
|
||||
|
||||
Higher values make pipenv more verbose, lower values less so. Default is 0,
|
||||
for normal verbosity.
|
||||
"""
|
||||
|
||||
PIPENV_YES = bool(os.environ.get("PIPENV_YES"))
|
||||
"""If set, Pipenv automatically assumes "yes" at all prompts.
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import pytest
|
||||
import mock
|
||||
|
||||
from pipenv.core import warn_in_virtualenv
|
||||
|
||||
|
||||
@mock.patch('pipenv.environments.PIPENV_VIRTUALENV', 'totallyrealenv')
|
||||
@mock.patch('pipenv.environments.PIPENV_VERBOSITY', -1)
|
||||
@pytest.mark.core
|
||||
def test_suppress_nested_venv_warning(capsys):
|
||||
# Capture the stderr of warn_in_virtualenv to test for the presence of the
|
||||
# courtesy notice.
|
||||
warn_in_virtualenv()
|
||||
output, err = capsys.readouterr()
|
||||
assert 'Courtesy Notice' not in err
|
||||
Reference in New Issue
Block a user