GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improve the documentation for `ignore_warnings` · Issue #103109 · python/cpython

Improve the documentation for ignore_warnings #103109

New issue
Copy link
New issue
Copy link
Closed
Closed
Improve the documentation for ignore_warnings#103109
Copy link
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-featureA feature request or enhancementA feature request or enhancement

Description

@CharlieZhao95
CharlieZhao95
opened on Mar 29, 2023
Issue body actions

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` statement
def test_suppress_warning():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore", category=SyntaxWarning)
        # do something

# use decorator
@warning_helper.ignore_warnings(category=SyntaxWarning)
def test_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

  • gh-103109: Add documentation for ignore_warnings #103110
  • [3.11] gh-103109: Document ignore_warnings() test support helper (GH-103110) #103198
  • [3.10] gh-103109: Document ignore_warnings() test support helper (GH-103110) #103199

Activity

  1. CharlieZhao95
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Mar 29, 2023
  2. arhadthedev
    added
    testsTests in the Lib/test dirTests in the Lib/test dir
    type-featureA feature request or enhancementA feature request or enhancement
    and removed
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Mar 30, 2023
  3. erlend-aasland
    added a commit that references this issue on Apr 2, 2023

    gh-103109: Document ignore_warnings() test support helper (#103110)

    32937d6
  4. miss-islington
    added 2 commits that reference this issue on Apr 2, 2023

    pythongh-103109: Document ignore_warnings() test support helper (pyth…

    c685ab9

    pythongh-103109: Document ignore_warnings() test support helper (pyth…

    13e18c9
  5. erlend-aasland commented on Apr 2, 2023

    @erlend-aasland
    erlend-aasland
    on Apr 2, 2023
    Contributor
    More actions

    Fixing the docstring and adding documentation seems enough for now. AFAIK, there is no need for adding a default value (consistency with warnings.simplefilter is not reason enough IMO). Marking this as closed.

  6. erlend-aasland
    closed this as completedon Apr 2, 2023
  7. miss-islington
    added 2 commits that reference this issue on Apr 2, 2023

    gh-103109: Document ignore_warnings() test support helper (GH-103110)

    9a8ce95

    gh-103109: Document ignore_warnings() test support helper (GH-103110)

    0854bdf
  8. gaogaotiantian
    added a commit that references this issue on Apr 8, 2023

    pythongh-103109: Document ignore_warnings() test support helper (pyth…

    ced3c8b
  9. warsaw
    added a commit that references this issue on Apr 11, 2023

    pythongh-103109: Document ignore_warnings() test support helper (pyth…

    a1e44a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.