コード例 #1
0
    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)
コード例 #2
0
 def test_catch_repr(self):
     f = lambda _: _
     assert (
         repr(effect.catch(Exception)(f)(0)
              ) == f'catch(<class \'Exception\'>)({repr(f)})(0)'
     )
コード例 #3
0
ファイル: test_effect.py プロジェクト: thomhickey/pfun
 def test_catch_io_bound(self, f):
     assert effect.catch(Exception)(effect.io_bound(f)
                                    )(None).run(None) == f(None)