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)
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)
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)
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)
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)
def test_raise_1(self): with self.assertRaises(SampleError): zz.raise_(SampleError("Test"))