Internal Testing Modules

test.support.warnings_helper

Provides warning-related fixtures for CPython tests. check_warnings checks expected message patterns and categories; ignore_warnings can temporarily suppress selected categories. Application tests should normally use warnings.catch_warnings or unittest assertions. This is CPython test infrastructure, not a supported application dependency; prefer public unittest or standard-library equivalents in application tests.

Formal Syntax & Structure

python syntaxpython
import test.support.warnings_helper

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
import warningsfrom test.support.warnings_helper import check_warningswith check_warnings(("demo", UserWarning)):    warnings.warn("demo", UserWarning)print("Warning matched")
Python Reference