Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #5
0
 def test_is_decorator(self):
     self.assertTrue(callable(retry(lambda: None)))
Exemple #6
0
 def test_is_decorator(self):
     self.assertTrue(callable(retry(lambda: None)))