Skip to content
Snippets Groups Projects
Commit 899da93e authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

fix

parent b6a011cc
No related branches found
No related tags found
No related merge requests found
......@@ -19,10 +19,10 @@ def silence_excs(*exc_types):
class rethrow_as(object):
"""Decorator + context manager"""
def __init__(self, *pairs, exception_preprocessor=repr):
def __init__(self, *pairs, **kwargs):
self.to_catch = tuple(p[0] for p in pairs)
self.pairs = pairs
self.exception_preprocessor = exception_preprocessor
self.exception_preprocessor = kwargs.get('exception_preprocessor', repr)
def __call__(self, fun):
@functools.wraps(fun)
......
......@@ -7,6 +7,10 @@ from satella.coding import rethrow_as, silence_excs
class TestStuff(unittest.TestCase):
@silence_excs(ValueError)
def test_silencer_2(self):
raise ValueError()
def test_silencer(self):
with silence_excs(TypeError):
raise TypeError()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment