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
Enable warnings by default in unittest #54744
Comments
Warnings should be on by default in unittest so that developers can see them while running the tests even if they are silenced by default in Python. The plan is to add a "warnings" argument to TestProgram and the default TextTestRunner:
In order to prevent floods of warnings when the deprecated assertEquals, assert_, etc. are used (see bpo-9424), a new type of warning could be created (e.g. _UnittestDeprecationWarning) and filtered so that these warnings are printed only once. |
Here's a working patch (without docs and tests). Regrtest doesn't seem to use unittest, so it should be fixed separately (probably needs another issue). |
"I'm also thinking that it might be better to include the name of the deprecated method in the message and use three filters for fail* methods, assert* methods, and the assert*Regexp* methods that will be deprecated." That sounds good, well - it sounds *essential*. |
Attached a new patch. A few comments about it:
|
Committed in r86908. I'll leave this open because there still a few things (proposed in the previous message) that can be changed/improved. |
Here's a patch for the ResourceWarnings that were introduced. |
Does Brian's patch still need applying? (Can this be closed?) |
Brian's patch is not yet applied afaik, but I couldn't see the warnings here, so it might be something specific to Windows. Brian, can you confirm if you still see the problem? Changing the warning type (to UnittestWarning) and the error message can still be done if you think it's a good idea. Since this fix didn't affect regrtest, another issue for it might be necessary too. |
I'm not seeing those warnings anymore, so I think the patch can be ignored. |
Ezio, do you want to create separate issues for any of the TODOs you wanted in http://bugs.python.org/issue10535#msg122779 so we can close this bug? |
The two TODOs left are:
Technically these are new features, so they can go in 3.4 only, but 2) might be simple enough to be backported. |
I wouldn't backport; not worth it. Anyway, since I consider this bug closed I'm taking myself off the nosy list. |
Agreed, closing. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: