Exemplo n.º 1
0
    def test_raises_when_fails(self):
        calls = []
        def lossy():
            calls.append(1)
            raise ValueError("Blah")

        f = retry(4, exceptions=ValueError)(lossy)
        self.assertRaises(ValueError, f)
        self.assertEqual(len(calls), 4)
Exemplo n.º 2
0
    def test_raises_when_fails(self):
        calls = []

        def lossy():
            calls.append(1)
            raise ValueError("Blah")

        f = retry(4, exceptions=ValueError)(lossy)
        self.assertRaises(ValueError, f)
        self.assertEqual(len(calls), 4)
Exemplo n.º 3
0
    def test_retries_once(self):
        calls = []
        def lossy():
            if not calls:
                calls.append(1)
                raise ValueError("Blah")
            return 42

        f = retry(exceptions=ValueError)(lossy)
        self.assertEqual(f(), 42)
        self.assertEqual(len(calls), 1)
Exemplo n.º 4
0
    def test_retries_once(self):
        calls = []

        def lossy():
            if not calls:
                calls.append(1)
                raise ValueError("Blah")
            return 42

        f = retry(exceptions=ValueError)(lossy)
        self.assertEqual(f(), 42)
        self.assertEqual(len(calls), 1)
Exemplo n.º 5
0
 def test_is_decorator(self):
     self.assertTrue(callable(retry(lambda: None)))
Exemplo n.º 6
0
 def test_is_decorator(self):
     self.assertTrue(callable(retry(lambda: None)))