checkwarns
¶
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 |
ErrorWarnings
¶
-
class
nibabel.checkwarns.
ErrorWarnings
(record=True, module=None)¶ Bases:
warnings.catch_warnings
Context manager to check for warnings as errors. Usually used with
assert_raises
in the with blockExamples
>>> with ErrorWarnings(): ... try: ... warnings.warn('Message', UserWarning) ... except UserWarning: ... print('I consider myself warned') I consider myself warned
-
__init__
(record=True, module=None)¶
-
filter
= 'error'¶
-
IgnoreWarnings
¶
-
class
nibabel.checkwarns.
IgnoreWarnings
(record=True, module=None)¶ Bases:
nibabel.checkwarns.ErrorWarnings
Context manager to ignore warnings
Examples
>>> with IgnoreWarnings(): ... warnings.warn('Message', UserWarning)
(and you get no warning)
-
__init__
(record=True, module=None)¶
-
filter
= 'ignore'¶
-