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)
| 144 | |
| 145 | @contextlib.contextmanager |
| 146 | def 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 | |
| 163 | def _filterwarnings(filters, quiet=False): |
searching dependent graphs…