Skip to content

Commit 80aa443

Browse files
committed
Fixed #12979 -- allowed using savepoints in TestCase (i.e. tests with transactions disabled), convert the GetOrCreate tests to use this.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14061 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent c93f5e5 commit 80aa443

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

django/test/testcases.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ def to_list(value):
3737
real_rollback = transaction.rollback
3838
real_enter_transaction_management = transaction.enter_transaction_management
3939
real_leave_transaction_management = transaction.leave_transaction_management
40-
real_savepoint_commit = transaction.savepoint_commit
41-
real_savepoint_rollback = transaction.savepoint_rollback
4240
real_managed = transaction.managed
4341

4442
def nop(*args, **kwargs):
@@ -47,17 +45,13 @@ def nop(*args, **kwargs):
4745
def disable_transaction_methods():
4846
transaction.commit = nop
4947
transaction.rollback = nop
50-
transaction.savepoint_commit = nop
51-
transaction.savepoint_rollback = nop
5248
transaction.enter_transaction_management = nop
5349
transaction.leave_transaction_management = nop
5450
transaction.managed = nop
5551

5652
def restore_transaction_methods():
5753
transaction.commit = real_commit
5854
transaction.rollback = real_rollback
59-
transaction.savepoint_commit = real_savepoint_commit
60-
transaction.savepoint_rollback = real_savepoint_rollback
6155
transaction.enter_transaction_management = real_enter_transaction_management
6256
transaction.leave_transaction_management = real_leave_transaction_management
6357
transaction.managed = real_managed

tests/modeltests/get_or_create/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from datetime import date
22

33
from django.db import IntegrityError
4-
from django.test import TransactionTestCase
4+
from django.test import TestCase
55

66
from models import Person, ManualPrimaryKeyTest
77

88

9-
class GetOrCreateTests(TransactionTestCase):
9+
class GetOrCreateTests(TestCase):
1010
def test_get_or_create(self):
1111
p = Person.objects.create(
1212
first_name='John', last_name='Lennon', birthday=date(1940, 10, 9)

0 commit comments

Comments
 (0)