diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2023-04-24 11:21:33 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-24 10:21:33 -0700 |
commit | d223d82372e08fcca1fa4e06eed8f4b52fe89b18 (patch) | |
tree | 06d92013f24444a786ca65b042c70b2c8de209b6 | |
parent | 47f13f5140a3f9235ea48596df3e86f08b03ec9d (diff) | |
download | tox-git-release-4.5.0.tar.gz |
Feature: suppress step timings for verbosity=1 #2891 (#2992)release-4.5.0
-rw-r--r-- | docs/changelog/2891.feature.rst | 2 | ||||
-rw-r--r-- | src/tox/session/cmd/run/common.py | 2 | ||||
-rw-r--r-- | tests/session/cmd/test_sequential.py | 10 |
3 files changed, 13 insertions, 1 deletions
diff --git a/docs/changelog/2891.feature.rst b/docs/changelog/2891.feature.rst new file mode 100644 index 00000000..a846cb60 --- /dev/null +++ b/docs/changelog/2891.feature.rst @@ -0,0 +1,2 @@ +When run with verbosity=1, the per-step timing summaries are suppressed at the +end of the run. Thanks to :user:`nedbat` at the PyCon 2023 sprints. diff --git a/src/tox/session/cmd/run/common.py b/src/tox/session/cmd/run/common.py index 73facf62..49aeb87b 100644 --- a/src/tox/session/cmd/run/common.py +++ b/src/tox/session/cmd/run/common.py @@ -174,7 +174,7 @@ def report(start: float, runs: list[ToxEnvRunResult], is_colored: bool, verbosit for run in runs: successful.append(run.code == Outcome.OK or run.ignore_outcome) skipped.append(run.skipped) - duration_individual = [o.elapsed for o in run.outcomes] + duration_individual = [o.elapsed for o in run.outcomes] if verbosity >= 2 else [] extra = f"+cmd[{','.join(f'{i:.2f}' for i in duration_individual)}]" if duration_individual else "" setup = run.duration - sum(duration_individual) msg, color = _get_outcome_message(run) diff --git a/tests/session/cmd/test_sequential.py b/tests/session/cmd/test_sequential.py index f3bd9231..c3e747e5 100644 --- a/tests/session/cmd/test_sequential.py +++ b/tests/session/cmd/test_sequential.py @@ -44,6 +44,16 @@ def test_run_sequential_fail(tox_project: ToxProjectCreator) -> None: assert Matches(r" a: FAIL code 1 \(.*=setup\[.*\]\+cmd\[.*\] seconds\)") == reports[-3] +def test_run_sequential_quiet(tox_project: ToxProjectCreator) -> None: + ini = "[tox]\nenv_list=a\nno_package=true\n[testenv]\ncommands=python -V" + project = tox_project({"tox.ini": ini}) + outcome = project.run("r", "-q", "-e", "a") + outcome.assert_success() + reports = outcome.out.splitlines()[-3:] + assert Matches(r" congratulations :\) \(.* seconds\)") == reports[-1] + assert Matches(r" a: OK \([\d.]+ seconds\)") == reports[-2] + + @pytest.mark.integration() def test_result_json_sequential( tox_project: ToxProjectCreator, |