mirror of https://github.com/flaggo/pydu.git
add exception.ignore
This commit is contained in:
parent
f826b33400
commit
d6bd7d7214
|
@ -0,0 +1,9 @@
|
|||
from contextlib import contextmanager
|
||||
|
||||
|
||||
@contextmanager
|
||||
def ignore(*exceptions):
|
||||
try:
|
||||
yield
|
||||
except exceptions:
|
||||
pass
|
|
@ -0,0 +1,7 @@
|
|||
from pydu.exception import ignore
|
||||
|
||||
|
||||
def test_ignore():
|
||||
with ignore(ValueError, AttributeError):
|
||||
int('abc')
|
||||
int.no_exists_func()
|
Loading…
Reference in New Issue