Skip to content

-vv should not override --durations-min #12938

Description

@JulianJvn

What's the problem this feature will solve?

I'd like pytest to give the full output on test failures for debugging purposes (by specifying -vv) while still being able to print the durations of tests and fixtures that exceed a given threshold (by using --durations-min).

  • It's not documented neither in pytest --help nor in the documentation that --durations-min has no effect if -vv is specified. I had to look at pytest's code to learn this:
    if verbose < 2 and rep.duration < durations_min:
    The documentation only says the default behavior is equivalent to --durations-min 0.005 to when -vv is not specified. It does not say custom --durations-min values have no effect if -vv is specified. So, if this issue is not implemented, it is at least a documentation bug.
  • It's asymmetric/inconsistent that --durations still has effect if -vv specified, but --durations-min does not.
  • It's unexpected that a more specific option like --durations-min is overridden by a less specific option like --verbose.

The options currently work like this, depending if they're specified (Y) or not (N) or if it doesn't matter whether they're specified or not (*):

--durations=N --durations-min=X -vv Behavior
N * * No durations are displayed
Y N N Top N durations with duration ≥ 0.005s are displayed
Y Y N Top N durations with duration ≥ X are displayed
Y * Y Top N durations are displayed

Describe the solution you'd like

If --durations-min is explicitly specified, it should have precedence over -vv. The options could work like this:

--durations=N --durations-min=X -vv Behavior
N * * No durations are displayed
Y N N Top N durations with duration ≥ 0.005s are displayed
Y N Y Top N durations are displayed
Y Y * Top N durations with duration ≥ X are displayed

Alternative Solutions

Another possibility that would work for me is removing the feature that -vv changes the default value of --durations-min, i.e., the options would be decoupled. The previous behavior could be easily restored with --durations-min=0. The options would then work like this:

--durations=N --durations-min=X -vv Behavior
N * * No durations are displayed
Y N * Top N durations with duration ≥ 0.005s are displayed
Y Y * Top N durations with duration ≥ X are displayed

Additional context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions