MCPcopy Index your code
hub / github.com/python/cpython / check_warnings

Function check_warnings

Lib/test/support/warnings_helper.py:97–117  ·  view source on GitHub ↗

Context manager to silence warnings. Accept 2-tuples as positional arguments: ("message regexp", WarningCategory) Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing (default True without argument, default False if some filter

(*filters, **kwargs)

Source from the content-addressed store, hash-verified

95
96@contextlib.contextmanager
97def check_warnings(*filters, **kwargs):
98 """Context manager to silence warnings.
99
100 Accept 2-tuples as positional arguments:
101 ("message regexp", WarningCategory)
102
103 Optional argument:
104 - if 'quiet' is True, it does not fail if a filter catches nothing
105 (default True without argument,
106 default False if some filters are defined)
107
108 Without argument, it defaults to:
109 check_warnings(("", Warning), quiet=True)
110 """
111 quiet = kwargs.get('quiet')
112 if not filters:
113 filters = (("", Warning),)
114 # Preserve backward compatibility
115 if quiet is None:
116 quiet = True
117 return _filterwarnings(filters, quiet)
118
119
120@contextlib.contextmanager

Callers 9

setUpMethod · 0.90
test_execMethod · 0.90
test_non_str_argumentMethod · 0.90
testWarningsMethod · 0.90
test_open_codeMethod · 0.90

Calls 2

_filterwarningsFunction · 0.85
getMethod · 0.45

Tested by 9

setUpMethod · 0.72
test_execMethod · 0.72
test_non_str_argumentMethod · 0.72
testWarningsMethod · 0.72
test_open_codeMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…