Exemple #1
0
 def test_func_that_raises_wrong_exception_type_should_raise(self):
     with raises(Exception) as e:
         retry.call(
             get_dummy_func(5),
             exceptions=[TypeError],
         )
     assert str(e.value) == 'Test Error 1'
Exemple #2
0
 def test_retry_with_wait_function(self, mock_sleep):
     retry.call(get_dummy_func(), wait=lambda n: n)
     mock_sleep.assert_called_with(4)
Exemple #3
0
 def test_retry_func_with_kwarg(self):
     result = retry.call(get_dummy_func(), kwargs={'foo': 'bar'})
     assert result == (CallCounter(5, 4), (), {'foo': 'bar'})
Exemple #4
0
 def test_retry_func_with_postional_arg(self):
     result = retry.call(get_dummy_func(), args=['foo'])
     assert result == (CallCounter(5, 4), ('foo', ), {})
Exemple #5
0
 def test_func_with_positional_arg(self):
     assert retry.call(lambda x: x, args=['bar']) == 'bar'
Exemple #6
0
 def test_func_that_fails_check_raises(self):
     with raises(Exception) as e:
         retry.call(get_dummy_func(5), check=lambda e, c: c != 3)
     assert str(e.value) == 'Test Error 3'
Exemple #7
0
 def test_func_that_passes_check_does_not_raise(self):
     result = retry.call(
         get_dummy_func(),
         check=lambda e, c: True,
     )
     assert result == (CallCounter(5, 4), (), {})
Exemple #8
0
 def test_func_that_raises_too_many_time_raises(self):
     with raises(Exception) as e:
         retry.call(get_dummy_func(50))
     assert str(e.value) == 'Test Error 5'
Exemple #9
0
 def test_retry_func_with_no_args(self):
     result = retry.call(get_dummy_func())
     assert result == (CallCounter(5, 4), (), {})