-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
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 --helpnor in the documentation that--durations-minhas no effect if-vvis specified. I had to look at pytest's code to learn this:The documentation only says the default behavior is equivalent toLine 93 in 3ef3c2d
if verbose < 2 and rep.duration < durations_min: --durations-min 0.005to when-vvis not specified. It does not say custom--durations-minvalues have no effect if-vvis specified. So, if this issue is not implemented, it is at least a documentation bug. - It's asymmetric/inconsistent that
--durationsstill has effect if-vvspecified, but--durations-mindoes not. - It's unexpected that a more specific option like
--durations-minis 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
—