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

Add -rW option to print captured warnings even for passing tests #3633

Closed
nicoddemus opened this issue Jun 28, 2018 · 9 comments
Closed

Add -rW option to print captured warnings even for passing tests #3633

nicoddemus opened this issue Jun 28, 2018 · 9 comments
Labels
good first issue easy issue that is friendly to new contributor plugin: warnings related to the warnings builtin plugin type: enhancement new feature or API change, should be merged into features branch

Comments

@nicoddemus
Copy link
Member

Follow up to #3621 (comment)

@nicoddemus nicoddemus added type: enhancement new feature or API change, should be merged into features branch plugin: warnings related to the warnings builtin plugin good first issue easy issue that is friendly to new contributor labels Jun 28, 2018
@nicoddemus
Copy link
Member Author

#1232 can be used as basis to implement this.

@pytestbot
Copy link
Contributor

GitMate.io thinks possibly related issues are #3251 (Warnings not captured during test collection), #1370 (Print out pytest-warnings?), #2178 (output capture broken when sys.stdout passed to print()), #1173 (Option to treat warnings as errors), and #2191 (add an option to warn about Python 3.x possible incompatibilities).

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 28, 2018
@nicoddemus nicoddemus removed the type: bug problem that needs to be addressed label Jun 28, 2018
@jucaleb4
Copy link

jucaleb4 commented Jul 2, 2018

Hi, can I help contribute to this one? @nicoddemus

@nicoddemus
Copy link
Member Author

Sure @jucaleb4, please go ahead! 👍

@jucaleb4
Copy link

jucaleb4 commented Jul 3, 2018

Awesome, thanks! I'll ask questions as they come along

@KamRon-67
Copy link

@nicoddemus has there been a solution merged? I am seeing seeing logic for the -rw option here https://github.com/pytest-dev/pytest/search?q=-rw&unscoped_q=-rw

@caramelomartins
Copy link
Contributor

@KamRon-67 I think there's a subtlety here, which I'll try to convey properly.

Currently, -rW is implemented to report on warnings but it only displays those warnings on unsuccessful runs. What has been request in #3621 is for -rW to display those warnings even when runs are successful, such as rP does. I hope thos makes sense?

Anyone, please correct me if I understood this wrong.

@vbarbaresi
Copy link
Member

I looked into this and I believe it doesn't apply anymore (partly due to PR #3931)
-rw option doesn't exist anymore, the CLI documentation says:

                      Warnings are displayed at all times except when
                        --disable-warnings is set
  --disable-warnings, --disable-pytest-warnings
                        disable warnings summary

A simple test shows that it works indeed, running pytest without any options gives you a warning summary

import warnings

def test_success():
    warnings.warn("hello")
    return True

In the example described in #3621 (comment), it's about an error inside a callback, not really a warning. I think it's the expected behavior: you wouldn't see the error running this code without pytest either.

@nicoddemus
Copy link
Member Author

Indeed, thanks @vbarbaresi for reviewing this. 👍

Closing then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue easy issue that is friendly to new contributor plugin: warnings related to the warnings builtin plugin type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

6 participants