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

terminal: default to fE with -r (reportchars) #6524

Merged
merged 1 commit into from
Jan 29, 2020

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Jan 21, 2020

Fixes #6454

@blueyed blueyed force-pushed the reportchars-default branch 2 times, most recently from ca73965 to b70aa10 Compare January 21, 2020 21:24
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but we should hear from @The-Compiler and @asottile because they were strongly against this change initially.

@asottile
Copy link
Member

asottile commented Jan 21, 2020

I'm still opposed to making the (already bad) situation worse with needing to scroll for error messages worse

I think I'd be less opposed to this change if we reordered the output so that warnings / logging / etc. are above the stacktraces.

I realize that relative to output / warnings this tends to be only a few lines instead of hundreds, though in larger testsuites this still adds an unwieldy amount of output.

@nicoddemus
Copy link
Member

Thanks @asottile,

I'm still opposed to making the (already bad) situation worse with needing to scroll for error messages worse

We are still talking about a few lines though. If you don't have any failures, the new default won't show a summary at all. If there are failures, in addition to several lines of tracebacks (hundreds unless using --tb=short) you will also get a 1 line summary per failed test.

I understand your sentiment of "this will make things a bit worse", but I think this is a matter of preference: when you see the current output you think that it is bad, so adding a few lines to the end probably won't make things that much worse for you anyway.

On the other hand it will make things more pleasant and useful for people who prefer to see a short summary of failures at the end (like myself and @blueyed). We already show a lot of information anyway by default, I believe a few more lines won't make it that worse for you.

I also agree with the sentiment in general of having a separate option to obtain a leaner output (#6471).

@asottile
Copy link
Member

I would have no opposition to this if it were an option, but I'd like to see pytest's default be less noisy wherever possible (a slim option I don't think actually addresses the problem that pytest's output is a lot of noise and very little signal by default)

@nicoddemus
Copy link
Member

I would have no opposition to this if it were an option

It is already an option, you can use -rfE explicitly.

but I'd like to see pytest's default be less noisy wherever possible

I see, but having pytest being less verbose by default is a separate (and more controversial) proposal.

For example, suppose we can give a grade for verbosity, and currently pytest is 8. This proposal is a small increase to that, to say 9. But what you actually want is to reduce verbosity a lot by default, say 2 or 3.

I understand the sentiment, but that's a different take and separate proposal from this one.

@asottile
Copy link
Member

if we take that since, the next small change will make it a 10 and then 11 and then 12 -- in my opinion directionally this pr is worse and sets a bad precedent

@nicoddemus
Copy link
Member

if we take that since, the next small change will make it a 10 and then 11 and then 12 -- in my opinion directionally this pr is worse and sets a bad precedent

Well I disagree, but I think I've laid all the arguments I had to convince you otherwise, so that's that.

Personally the summary is the first thing I miss once I get more than 1 or 2 failures, so this PR is beneficial in my eyes.

Let's see what others have to say then, if more people feel the same we should then discard the proposal and the PR.

Copy link
Member

@The-Compiler The-Compiler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on this PR (other than the thing I've commented on). IMHO it might make the situation better, because you don't necessarily need to scroll through the output anymore when you see a summary of the failures. I was only opposed to making it -ra by default (like the title of #6454 suggested at the time I replied).

@blueyed blueyed force-pushed the reportchars-default branch from b70aa10 to 5fe1fdf Compare January 22, 2020 11:18
- ``a`` - all except ``pP``
- ``A`` - all
- ``N`` - none, this can be used to display nothing (since ``fE`` is the default)

More than one character can be used, so for example to only see failed and skipped tests, you can execute:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also somehow mention that the effective default is wfE without --disable-warnings actually? (#5066)

Copy link
Member

@nicoddemus nicoddemus Jan 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, that got me thinking and I think -rw should be removed from the docs.

Since we have merged pytest-warnings (which seems like decades ago), -rw is not really a thing, because independently of what you put in -r (except N now in this PR) warnings are always displayed:

No -r option:

λ pytest .tmp\test-reporting.py
...
========================= warnings summary ==========================
test-reporting.py::test_warn
  D:\projects\pytest\.tmp\test-reporting.py:28: UserWarning: some warning
    warnings.warn(UserWarning('some warning'))

-- Docs: https://docs.pytest.org/en/latest/warnings.html
====================== short test summary info ======================
FAILED .tmp\test-reporting.py::test_fail[0] - assert 0
FAILED .tmp\test-reporting.py::test_fail[1] - assert 0
FAILED .tmp\test-reporting.py::test_fail[2] - assert 0
=== 3 failed, 4 passed, 3 skipped, 3 xfailed, 1 warning in 0.11s ====

Some -r combination (note the missing w):

λ pytest .tmp\test-reporting.py -rXfs
...
========================= warnings summary ==========================
test-reporting.py::test_warn
  D:\projects\pytest\.tmp\test-reporting.py:28: UserWarning: some warning
    warnings.warn(UserWarning('some warning'))

-- Docs: https://docs.pytest.org/en/latest/warnings.html
====================== short test summary info ======================
FAILED .tmp\test-reporting.py::test_fail[0] - assert 0
FAILED .tmp\test-reporting.py::test_fail[1] - assert 0
FAILED .tmp\test-reporting.py::test_fail[2] - assert 0
SKIPPED [3] test-reporting.py:15: nas
=== 3 failed, 4 passed, 3 skipped, 3 xfailed, 1 warning in 0.12s ====

So the only way to skip the warnings summary section is by using either -rN or --disable-warnings, as of now.

Warnings being controlled in -r is historical left-over, so much that warnings summary and short test summary are separate today.

I propose then:

  • Remove -rw from the docs, given it doesn't do anything (or mention that it is there for historical reasons but has no effect).
  • Make -rN not affect warnings at all, warnings can already be disabled with --disable-warnings. No backward compatibility here to consider because N is new, and the only way to hide warnings is with --disable-warnings anyway. This also makes using -rN produce the exact same behavior as before: hide short test summary, but warnings summary is still shown.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicoddemus have you looked at #5066 again?
There we wanted something like -r-w and remove/deprecate the option completely even.

This comment was marked as duplicate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I didn't, even thought you mentioned it, my bad.

I've re-read that thread, and I still think what I wrote above holds better, specially because warnings and short summaries are reported and dealt separately. It also means we wouldn't need to deprecate anything really.

@bluetech
Copy link
Member

I still would have preferred X (xpassed) to be included, however seems others disagree, due to some test suites abusing(?) it. So 👍 from me (I didn't review the code).

@blueyed
Copy link
Contributor Author

blueyed commented Jan 23, 2020

I still would have preferred X (xpassed) to be included

Good point.

however seems others disagree

I think it makes sense also.

due to some test suites abusing(?) it.

IIRC I've found a reference to it somewhere and just mentioned it (#6454 (comment)).
AFAICS nobody disagrees?

@nicoddemus
Copy link
Member

So 👍 from me (I didn't review the code).

Feel free to approve the PR then. 😁

AFAICS nobody disagrees?

Perhaps we should be conservative and just stick with fE for now?

@blueyed
Copy link
Contributor Author

blueyed commented Jan 23, 2020

So +1 from me (I didn't review the code).

Feel free to approve the PR then.

Without an actual review? 😕

AFAICS nobody disagrees?

Perhaps we should be conservative and just stick with fE for now?

Yeah, ok - needs another pass to address your feedback anyway, so I've thought it could go in still also. But we can create a followup issue for it then.

@nicoddemus

This comment has been minimized.

@blueyed blueyed force-pushed the reportchars-default branch from 5fe1fdf to f239576 Compare January 26, 2020 23:03
@blueyed
Copy link
Contributor Author

blueyed commented Jan 26, 2020

Amended for N to not reset w.
Moved handling of w to the end also, since "warnings and short summaries are reported and dealt separately" according to #6524 (comment).

This also changes the weird behavior that -ra and -rA would previously include warnings even though --disable-warnings was used.

@blueyed
Copy link
Contributor Author

blueyed commented Jan 26, 2020

This also changes the weird behavior that -ra and -rA would previously include warnings even though --disable-warnings was used.

Might be worth a separate changelog entry?

@blueyed blueyed force-pushed the reportchars-default branch 2 times, most recently from a53d6b6 to 2973ce1 Compare January 27, 2020 23:59
@nicoddemus
Copy link
Member

Might be worth a separate changelog entry?

Sounds good, but you might just use the same entry and just add another paragraph (your call). 👍

Adds handling of `N` to reset `reportchars`, which can be used to get
the old behavior (`-rN`), and also allows for an alternative to
`--disable-warnings` (pytest-dev#5066),
since `w` was included by default (without `--disable-warnings`).

Fixes pytest-dev#6454
@blueyed blueyed force-pushed the reportchars-default branch from 2973ce1 to ddaa5d8 Compare January 28, 2020 23:33
@blueyed
Copy link
Contributor Author

blueyed commented Jan 28, 2020

Added changelog/6454.bugfix.rst.

@blueyed
Copy link
Contributor Author

blueyed commented Jan 28, 2020

Will merge once CI passes.

@blueyed blueyed merged commit 3ccf2a5 into pytest-dev:features Jan 29, 2020
@blueyed blueyed deleted the reportchars-default branch January 29, 2020 00:00
blueyed added a commit to blueyed/pytest that referenced this pull request Jan 30, 2020
`-fE` is the default in `features` now [1], but the idea is to add `X`
also to it in the long run, so let's dogfood it ourselves.

1: pytest-dev#6524
2: pytest-dev#6524 (comment)
@blueyed blueyed mentioned this pull request Jan 30, 2020
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

Successfully merging this pull request may close these issues.

6 participants