Append a new recording filter or apply it if the state is entered. All warnings matching will be appended to the ``log`` attribute. Parameters ---------- category : class, optional Warning class to filter message : string, optional
(self, category=Warning, message="", module=None)
| 2444 | record=False) |
| 2445 | |
| 2446 | def record(self, category=Warning, message="", module=None): |
| 2447 | """ |
| 2448 | Append a new recording filter or apply it if the state is entered. |
| 2449 | |
| 2450 | All warnings matching will be appended to the ``log`` attribute. |
| 2451 | |
| 2452 | Parameters |
| 2453 | ---------- |
| 2454 | category : class, optional |
| 2455 | Warning class to filter |
| 2456 | message : string, optional |
| 2457 | Regular expression matching the warning message. |
| 2458 | module : module, optional |
| 2459 | Module to filter for. Note that the module (and its file) |
| 2460 | must match exactly and cannot be a submodule. This may make |
| 2461 | it unreliable for external modules. |
| 2462 | |
| 2463 | Returns |
| 2464 | ------- |
| 2465 | log : list |
| 2466 | A list which will be filled with all matched warnings. |
| 2467 | |
| 2468 | Notes |
| 2469 | ----- |
| 2470 | When added within a context, filters are only added inside |
| 2471 | the context and will be forgotten when the context is exited. |
| 2472 | """ |
| 2473 | return self._filter(category=category, message=message, module=module, |
| 2474 | record=True) |
| 2475 | |
| 2476 | def __enter__(self): |
| 2477 | if self._entered: |