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_warningsContext manager to check for warnings as errors. Usually used with
assert_raisesin 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.ErrorWarningsContext manager to ignore warnings
Examples
>>> with IgnoreWarnings(): ... warnings.warn('Message', UserWarning)
(and you get no warning)
-
__init__(record=True, module=None)¶
-
filter= 'ignore'¶
-
