mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-28 11:25:42 +08:00
Cleanup the _warnings module
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
__all__ = ['all_warnings', 'expected_warnings']
|
||||
|
||||
from contextlib import contextmanager
|
||||
import sys
|
||||
import warnings
|
||||
import inspect
|
||||
import re
|
||||
|
||||
__all__ = ['all_warnings', 'expected_warnings', 'warn']
|
||||
|
||||
|
||||
def warn(message, category=None, stacklevel=2):
|
||||
"""A version of `warnings.warn` with a default stacklevel of 2.
|
||||
@@ -98,7 +98,8 @@ def expected_warnings(matching):
|
||||
that may produce different warnings. The behaviors can be combined.
|
||||
If you pass multiple patterns, you get an orderless "and", where all of the
|
||||
warnings must be raised.
|
||||
If you use the "|" operator in a pattern, you can catch one of several warnings.
|
||||
If you use the "|" operator in a pattern, you can catch one of several
|
||||
warnings.
|
||||
Finally, you can use "|\A\Z" in a pattern to signify it as optional.
|
||||
|
||||
"""
|
||||
@@ -106,7 +107,7 @@ def expected_warnings(matching):
|
||||
# enter context
|
||||
yield w
|
||||
# exited user context, check the recorded warnings
|
||||
remaining = [m for m in matching if not '\A\Z' in m.split('|')]
|
||||
remaining = [m for m in matching if '\A\Z' not in m.split('|')]
|
||||
for warn in w:
|
||||
found = False
|
||||
for match in matching:
|
||||
|
||||
Reference in New Issue
Block a user