Ejemplo n.º 1
0
 def test_eintr_retry_succ(self):
     for r in ('OK', None):
         mock_system_call = mock.MagicMock(name='sys_call', return_value=r)
         return_value = cookbook.eintr_retry(mock_system_call)
         mock_system_call.assert_called_with()
         self.assertEqual(return_value, r)
         return_value = cookbook.eintr_retry(mock_system_call, 'A')
         mock_system_call.assert_called_with('A')
         self.assertEqual(return_value, r)
Ejemplo n.º 2
0
    def test_eintr_retry_err(self):
        mock_system_call = mock.MagicMock(name='sys_call', side_effect=OSError)

        with self.assertRaises(OSError) as err:
            cookbook.eintr_retry(mock_system_call)
            mock_system_call.assert_called_with()

        with self.assertRaises(OSError) as err:
            cookbook.eintr_retry(mock_system_call, 'A')
            mock_system_call.assert_called_with('A')