runUnitTest: show "default" warnings when running tests
By default, DeprecationWarning and PendingDeprecationWarning, and ImportWarning are ignored, we want to see those while running tests, so we reset the warnings module to use "default" behavior for all warnings. https://docs.python.org/3/library/warnings.html#default-warning-filter https://docs.python.org/2.7/library/warnings.html#updating-code-for-new-versions-of-python This also implements the recommendation from https://docs.python.org/3/library/warnings.html#overriding-the-default-filter > Developers of test runners for Python code are advised to instead > ensure that all warnings are displayed by default for the code under > test, using code like: import sys if not sys.warnoptions: import os, warnings warnings.simplefilter("default") # Change the filter in this process os.environ["PYTHONWARNINGS"] = "default" # Also affect subprocesses This also extend the "Run Live Test" action to allow controlling the warnings filter, but on python2 this does not work so well, once a warning was ignored, later switching to "always" or "error" does not process the warning again ( it might be because of https://bugs.python.org/issue4180 )
Showing
Please register or sign in to comment