Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JulianJvn opened this issue Nov 4, 2024 · 0 comments
Open

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

JulianJvn opened this issue Nov 4, 2024 · 0 comments

Comments

@JulianJvn
Copy link

JulianJvn commented Nov 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant