# Path: jacquard/storage/utils.py
# def retrying(fn):
#     """Decorator: reissues the function if it raises Retry."""
#     logger = logging.getLogger("jacquard.storage.retrying")
# 
#     @functools.wraps(fn)
#     def wrapper(*args, **kwargs):
#         while True:
#             try:
#                 return fn(*args, **kwargs)
#             except Retry:
#                 callable_name = getattr(fn, "__name__", "anonymous function")
#                 logger.debug("Retry issued from %s, reissuing", callable_name)
# 
#     return wrapper
# 
# Path: jacquard/storage/exceptions.py
# class Retry(Exception):
#     """
#     Raised in case of transaction commit failures.
# 
#     A request to re-try the transaction, in the hope that this time there are
#     no conflicts.
#     """
# 
#     pass


import unittest.mock
import pytest
from jacquard.storage.utils import retrying
from jacquard.storage.exceptions import Retry


def test_passes_through_args():
    mock_inner = unittest.mock.Mock()

    @retrying
    def fn(arg):
        mock_inner(arg)

    sentinel = object()
    fn(sentinel)
    mock_inner.assert_called_with(sentinel)


def test_passes_through_kwargs():
    mock_inner = unittest.mock.Mock()

    @retrying
    def fn(arg):
        mock_inner(arg)

    sentinel = object()
    fn(arg=sentinel)
    mock_inner.assert_called_with(sentinel)


def test_passes_through_return_values():
    sentinel = object()
    mock_inner = unittest.mock.Mock(return_value=sentinel)


# Path: jacquard/storage/utils.py
# def retrying(fn):
#     """Decorator: reissues the function if it raises Retry."""
#     logger = logging.getLogger("jacquard.storage.retrying")
# 
#     @functools.wraps(fn)
#     def wrapper(*args, **kwargs):
#         while True:
#             try:
#                 return fn(*args, **kwargs)
#             except Retry:
#                 callable_name = getattr(fn, "__name__", "anonymous function")
#                 logger.debug("Retry issued from %s, reissuing", callable_name)
# 
#     return wrapper
# 
# Path: jacquard/storage/exceptions.py
# class Retry(Exception):
#     """
#     Raised in case of transaction commit failures.
# 
#     A request to re-try the transaction, in the hope that this time there are
#     no conflicts.
#     """
# 
#     pass


# Path: jacquard/tests/test_reissue.py
import unittest.mock
import pytest
from jacquard.storage.utils import retrying
from jacquard.storage.exceptions import Retry



def test_passes_through_args():
    mock_inner = unittest.mock.Mock()

    @retrying
    def fn(arg):
        mock_inner(arg)

    sentinel = object()
    fn(sentinel)
    mock_inner.assert_called_with(sentinel)


def test_passes_through_kwargs():
    mock_inner = unittest.mock.Mock()

    @retrying
    def fn(arg):
        mock_inner(arg)

    sentinel = object()
    fn(arg=sentinel)
    mock_inner.assert_called_with(sentinel)


def test_passes_through_return_values():
    sentinel = object()
    mock_inner = unittest.mock.Mock(return_value=sentinel)


    @retrying