Documentation
Recently, I found that using ignore_warnings(*, category), a simple decorator in test.support.warning_helper, is sometimes a concise way to suppress warnings in test cases. For example:
# use `with` statementdeftest_suppress_warning():
withwarnings.catch_warnings():
warnings.simplefilter("ignore", category=SyntaxWarning)
# do something# use decorator@warning_helper.ignore_warnings(category=SyntaxWarning)deftest_suppress_warning():
# do somethingWhat I want to improve:
- The comment of function
ignore_warnings , it writes
Decorator to suppress deprecation warnings
But in fact this can become a more general warning suppression decorator, not just deprecation warnings, we can improve this comment.
- The document of test.support.warnings_helper, it is missing information about the function
ignore_warnings. - Perhaps we can also add a default value to it, just like
ignore_warnings(*, category=Warning), so that the behavior of this decorator is consistent with warnings.simplefilter.
Linked PRs
Documentation
Recently, I found that using
ignore_warnings(*, category), a simple decorator intest.support.warning_helper, is sometimes a concise way to suppress warnings in test cases. For example:What I want to improve:
ignore_warnings, it writesBut in fact this can become a more general warning suppression decorator, not just deprecation warnings, we can improve this comment.
ignore_warnings.ignore_warnings(*, category=Warning), so that the behavior of this decorator is consistent withwarnings.simplefilter.Linked PRs
ignore_warnings#103110