def test_catch(self): def f(fail): if fail: raise ValueError() else: return 1 assert effect.catch(ValueError)(f)(False).run(None) == 1 catched_error = effect.catch(ValueError)(f)(True) with pytest.raises(ValueError): catched_error.run(None)
def test_catch_repr(self): f = lambda _: _ assert ( repr(effect.catch(Exception)(f)(0) ) == f'catch(<class \'Exception\'>)({repr(f)})(0)' )
def test_catch_io_bound(self, f): assert effect.catch(Exception)(effect.io_bound(f) )(None).run(None) == f(None)