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)
| 2146 | record=False) |
| 2147 | |
| 2148 | def record(self, category=Warning, message="", module=None): |
| 2149 | """ |
| 2150 | Append a new recording filter or apply it if the state is entered. |
| 2151 | |
| 2152 | All warnings matching will be appended to the ``log`` attribute. |
| 2153 | |
| 2154 | Parameters |
| 2155 | ---------- |
| 2156 | category : class, optional |
| 2157 | Warning class to filter |
| 2158 | message : string, optional |
| 2159 | Regular expression matching the warning message. |
| 2160 | module : module, optional |
| 2161 | Module to filter for. Note that the module (and its file) |
| 2162 | must match exactly and cannot be a submodule. This may make |
| 2163 | it unreliable for external modules. |
| 2164 | |
| 2165 | Returns |
| 2166 | ------- |
| 2167 | log : list |
| 2168 | A list which will be filled with all matched warnings. |
| 2169 | |
| 2170 | Notes |
| 2171 | ----- |
| 2172 | When added within a context, filters are only added inside |
| 2173 | the context and will be forgotten when the context is exited. |
| 2174 | """ |
| 2175 | return self._filter(category=category, message=message, module=module, |
| 2176 | record=True) |
| 2177 | |
| 2178 | def __enter__(self): |
| 2179 | if self._entered: |