Contexts for with statement allowing checks for warnings
ErrorWarnings([record, module]) | Context manager to check for warnings as errors. |
IgnoreWarnings([record, module]) | Context manager to ignore warnings |
Bases: warnings.catch_warnings
Context manager to check for warnings as errors. Usually used with assert_raises in the with block
Examples
>>> with ErrorWarnings():
... try:
... warnings.warn('Message', UserWarning)
... except UserWarning:
... print('I consider myself warned')
I consider myself warned
Bases: nibabel.checkwarns.ErrorWarnings
Context manager to ignore warnings
Examples
>>> with IgnoreWarnings():
... warnings.warn('Message', UserWarning)
(and you get no warning)