Пример #1
0
    def test_synchronize(self):
        mock_func = mock.Mock()
        mock_lock = mock.Mock()

        decorated_func = synchronized(mock_lock)(mock_func)

        self.assertEqual(decorated_func(1, a=2), mock_func.return_value)

        mock_func.assert_called_once_with(1, a=2)
        mock_lock.acquire.assert_called_once()
        mock_lock.release.assert_called_once()
Пример #2
0
    def test_synchronize(self):
        mock_func = mock.Mock()
        mock_lock = mock.Mock()

        decorated_func = synchronized(mock_lock)(mock_func)

        self.assertEqual(decorated_func(1, a=2), mock_func.return_value)

        mock_func.assert_called_once_with(1, a=2)
        mock_lock.acquire.assert_called_once()
        mock_lock.release.assert_called_once()