MCPcopy Create free account
hub / github.com/python/cpython / check_no_resource_warning

Function check_no_resource_warning

Lib/test/support/warnings_helper.py:146–160  ·  view source on GitHub ↗

Context manager to check that no ResourceWarning is emitted. Usage: with check_no_resource_warning(self): f = open(...) ... del f You must remove the object which may emit ResourceWarning before the end of the context manager.

(testcase)

Source from the content-addressed store, hash-verified

144
145@contextlib.contextmanager
146def check_no_resource_warning(testcase):
147 """Context manager to check that no ResourceWarning is emitted.
148
149 Usage:
150
151 with check_no_resource_warning(self):
152 f = open(...)
153 ...
154 del f
155
156 You must remove the object which may emit ResourceWarning before
157 the end of the context manager.
158 """
159 with check_no_warnings(testcase, category=ResourceWarning, force_gc=True):
160 yield
161
162
163def _filterwarnings(filters, quiet=False):

Callers 1

test_ftp_no_leakMethod · 0.90

Calls 1

check_no_warningsFunction · 0.85

Tested by 1

test_ftp_no_leakMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…