Ejemplo n.º 1
0
    def test_raise_2(self):
        def foo():
            raise SampleError()

        test = 0
        with self.assertRaises(SampleError):
            try:
                foo()
            except SampleError:
                test = 1
                zz.raise_()
        self.assertEqual(test, 1)
Ejemplo n.º 2
0
 def test_foldr_3(self):
     # Error if empty and no init
     func = lambda x, y: zz.raise_(Exception("This should not be called"))
     with self.assertRaises(zz.AlakazamError):
         zz.empty().foldr(func)
Ejemplo n.º 3
0
 def test_foldr_2(self):
     # Doesn't call the function on an empty sequence
     func = lambda x, y: zz.raise_(Exception("This should not be called"))
     self.assertEqual(zz.empty().foldr(func, init=1), 1)
Ejemplo n.º 4
0
 def test_foldr_lazy_2(self):
     func = lambda x, y: zz.raise_(Exception("This should not be called"))
     self.assertEqual(zz.empty().foldr_lazy(func, init=1), 1)
Ejemplo n.º 5
0
 def test_foldr_7(self):
     # Type errors during iteration get passed through
     func = lambda x, y: zz.raise_(
         TypeError("This exception should be raised"))
     with self.assertRaises(TypeError):
         zz.of([1, 2, 3, 4]).foldr(func)
Ejemplo n.º 6
0
 def test_raise_1(self):
     with self.assertRaises(SampleError):
         zz.raise_(SampleError("Test"))