mirror of
https://github.com/django/django.git
synced 2025-09-13 05:57:52 +00:00
Improved the API of set_autocommit.
This commit is contained in:
parent
f32100939e
commit
e654180ce2
8 changed files with 24 additions and 24 deletions
|
@ -269,19 +269,19 @@ class AtomicMergeTests(TransactionTestCase):
|
|||
class AtomicErrorsTests(TransactionTestCase):
|
||||
|
||||
def test_atomic_requires_autocommit(self):
|
||||
transaction.set_autocommit(autocommit=False)
|
||||
transaction.set_autocommit(False)
|
||||
try:
|
||||
with self.assertRaises(transaction.TransactionManagementError):
|
||||
with transaction.atomic():
|
||||
pass
|
||||
finally:
|
||||
transaction.set_autocommit(autocommit=True)
|
||||
transaction.set_autocommit(True)
|
||||
|
||||
def test_atomic_prevents_disabling_autocommit(self):
|
||||
autocommit = transaction.get_autocommit()
|
||||
with transaction.atomic():
|
||||
with self.assertRaises(transaction.TransactionManagementError):
|
||||
transaction.set_autocommit(autocommit=not autocommit)
|
||||
transaction.set_autocommit(not autocommit)
|
||||
# Make sure autocommit wasn't changed.
|
||||
self.assertEqual(connection.autocommit, autocommit)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue