Kaydet (Commit) 885d98d2 authored tarafından Aymeric Augustin's avatar Aymeric Augustin

Fixed #20028 -- Made atomic usable on callable instances.

Thanks Anssi for the report.
üst 4846e2b7
......@@ -17,6 +17,7 @@ import warnings
from functools import wraps
from django.db import connections, DatabaseError, DEFAULT_DB_ALIAS
from django.utils.decorators import available_attrs
class TransactionManagementError(Exception):
......@@ -313,7 +314,7 @@ class Atomic(object):
def __call__(self, func):
@wraps(func)
@wraps(func, assigned=available_attrs(func))
def inner(*args, **kwargs):
with self:
return func(*args, **kwargs)
......
......@@ -300,6 +300,17 @@ class AtomicErrorsTests(TransactionTestCase):
transaction.leave_transaction_management()
class AtomicMiscTests(TransactionTestCase):
def test_wrap_callable_instance(self):
# Regression test for #20028
class Callable(object):
def __call__(self):
pass
# Must not raise an exception
transaction.atomic(Callable())
class IgnorePendingDeprecationWarningsMixin(object):
def setUp(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment