Skip to content

Commit d223d82

Browse files
authored
Feature: suppress step timings for verbosity=1 #2891 (#2992)
1 parent 47f13f5 commit d223d82

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

docs/changelog/2891.feature.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
When run with verbosity=1, the per-step timing summaries are suppressed at the
2+
end of the run. Thanks to :user:`nedbat` at the PyCon 2023 sprints.

src/tox/session/cmd/run/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def _print(color_: int, message: str) -> None:
174174
for run in runs:
175175
successful.append(run.code == Outcome.OK or run.ignore_outcome)
176176
skipped.append(run.skipped)
177-
duration_individual = [o.elapsed for o in run.outcomes]
177+
duration_individual = [o.elapsed for o in run.outcomes] if verbosity >= 2 else []
178178
extra = f"+cmd[{','.join(f'{i:.2f}' for i in duration_individual)}]" if duration_individual else ""
179179
setup = run.duration - sum(duration_individual)
180180
msg, color = _get_outcome_message(run)

tests/session/cmd/test_sequential.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ def _cmd(value: int) -> str:
4444
assert Matches(r" a: FAIL code 1 \(.*=setup\[.*\]\+cmd\[.*\] seconds\)") == reports[-3]
4545

4646

47+
def test_run_sequential_quiet(tox_project: ToxProjectCreator) -> None:
48+
ini = "[tox]\nenv_list=a\nno_package=true\n[testenv]\ncommands=python -V"
49+
project = tox_project({"tox.ini": ini})
50+
outcome = project.run("r", "-q", "-e", "a")
51+
outcome.assert_success()
52+
reports = outcome.out.splitlines()[-3:]
53+
assert Matches(r" congratulations :\) \(.* seconds\)") == reports[-1]
54+
assert Matches(r" a: OK \([\d.]+ seconds\)") == reports[-2]
55+
56+
4757
@pytest.mark.integration()
4858
def test_result_json_sequential(
4959
tox_project: ToxProjectCreator,

0 commit comments

Comments
 (0)