Skip to content

Improve the documentation for ignore_warnings #103109

Description

@CharlieZhao95

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 something

What I want to improve:

  1. 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.

  1. The document of test.support.warnings_helper, it is missing information about the function ignore_warnings.
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions