Skip to content

Commit 3b91d63

Browse files
gaborbernatasottile
authored andcommitted
when verbosity level increases above two start passing through verbosity flags to pip #982 (#988)
1 parent 776a763 commit 3b91d63

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

changelog/982.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
when verbosity level increases above two start passing through verbosity flags to pip - by :user:`gaborbernat`

src/tox/_pytestplugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from tox import venv
1515
from tox.config import parseconfig
1616
from tox.result import ResultLog
17-
from tox.session import Session, main
17+
from tox.session import Reporter, Session, main
1818
from tox.venv import CreationConfig, VirtualEnv, getdigest
1919

2020
mark_dont_run_on_windows = pytest.mark.skipif(os.name == "nt", reason="non windows test")
@@ -128,6 +128,7 @@ def __init__(self, session):
128128
self._calls = []
129129
self._index = -1
130130
self.session = session
131+
self.orig_reporter = Reporter(session)
131132

132133
def clear(self):
133134
self._calls[:] = []
@@ -136,8 +137,7 @@ def __getattr__(self, name):
136137
if name[0] == "_":
137138
raise AttributeError(name)
138139
elif name == "verbosity":
139-
# FIXME: special case for property on Reporter class, may it be generalized?
140-
return 0
140+
return self.orig_reporter.verbosity
141141

142142
def generic_report(*args, **_):
143143
self._calls.append((name,) + args)

src/tox/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,9 @@ def tox_addoption(parser):
361361
action="count",
362362
dest="verbose_level",
363363
default=0,
364-
help="increase verbosity of reporting output. -vv mode turns off "
365-
"output redirection for package installation",
364+
help="increase verbosity of reporting output."
365+
"-vv mode turns off output redirection for package installation, "
366+
"above level two verbosity flags are passed through to pip (with two less level)",
366367
)
367368
parser.add_argument(
368369
"-q",

src/tox/venv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def install_pkg(self, dir, action, name, is_develop=False):
274274
return
275275
action.setactivity("{}-nodeps".format(name), dir)
276276
pip_flags = ["--no-deps"] + ([] if is_develop else ["-U"])
277-
277+
pip_flags.extend(["-v"] * min(3, action.report.verbosity - 2))
278278
if action.venv.envconfig.extras:
279279
dir += "[{}]".format(",".join(action.venv.envconfig.extras))
280280
target = [dir]

tests/unit/test_venv.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,20 @@ def test_installpkg_no_upgrade(tmpdir, newmocksession):
724724
assert pcalls[0].args[1:-1] == ["-m", "pip", "install", "--exists-action", "w"]
725725

726726

727+
@pytest.mark.parametrize("count, level", [(0, 0), (1, 0), (2, 0), (3, 1), (4, 2), (5, 3), (6, 3)])
728+
def test_install_command_verbosity(tmpdir, newmocksession, count, level):
729+
pkg = tmpdir.ensure("package.tar.gz")
730+
mock_session = newmocksession(["-{}".format("v" * count)], "")
731+
env = mock_session.getenv("python")
732+
env.just_created = True
733+
env.envconfig.envdir.ensure(dir=1)
734+
mock_session.installpkg(env, pkg)
735+
pcalls = mock_session._pcalls
736+
assert len(pcalls) == 1
737+
expected = ["-m", "pip", "install", "--exists-action", "w"] + (["-v"] * level)
738+
assert pcalls[0].args[1:-1] == expected
739+
740+
727741
def test_installpkg_upgrade(newmocksession, tmpdir):
728742
pkg = tmpdir.ensure("package.tar.gz")
729743
mocksession = newmocksession([], "")

0 commit comments

Comments
 (0)