MCPcopy Index your code
hub / github.com/RustPython/RustPython / check_warnings

Function check_warnings

Lib/test/support/warnings_helper.py:85–105  ·  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

83
84@contextlib.contextmanager
85def check_warnings(*filters, **kwargs):
86 """Context manager to silence warnings.
87
88 Accept 2-tuples as positional arguments:
89 ("message regexp", WarningCategory)
90
91 Optional argument:
92 - if 'quiet' is True, it does not fail if a filter catches nothing
93 (default True without argument,
94 default False if some filters are defined)
95
96 Without argument, it defaults to:
97 check_warnings(("", Warning), quiet=True)
98 """
99 quiet = kwargs.get('quiet')
100 if not filters:
101 filters = (("", Warning),)
102 # Preserve backward compatibility
103 if quiet is None:
104 quiet = True
105 return _filterwarnings(filters, quiet)
106
107
108@contextlib.contextmanager

Callers 9

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

Calls 2

_filterwarningsFunction · 0.85
getMethod · 0.45

Tested by 9

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