summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2012-06-08 15:57:42 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2012-11-15 17:31:08 +0200
commit71e14cf3aa024496adcb23e83ddf13a7c5ddeb32 (patch)
tree7830fde7af8a2d1821797a3ce1c2181f98c7976e
parentf51e409a5fb34020e170494320a421503689aea0 (diff)
Fixed #18347 -- Removed autofield raw SQL inserts from tests
-rw-r--r--tests/regressiontests/transactions_regress/tests.py25
1 files changed, 10 insertions, 15 deletions
diff --git a/tests/regressiontests/transactions_regress/tests.py b/tests/regressiontests/transactions_regress/tests.py
index 472e2aafd9..66e047799e 100644
--- a/tests/regressiontests/transactions_regress/tests.py
+++ b/tests/regressiontests/transactions_regress/tests.py
@@ -24,17 +24,15 @@ class TestTransactionClosing(TransactionTestCase):
def raw_sql():
"Write a record using raw sql under a commit_on_success decorator"
cursor = connection.cursor()
- cursor.execute("INSERT into transactions_regress_mod (id,fld) values (17,18)")
+ cursor.execute("INSERT into transactions_regress_mod (fld) values (18)")
raw_sql()
# Rollback so that if the decorator didn't commit, the record is unwritten
transaction.rollback()
- try:
- # Check that the record is in the DB
- obj = Mod.objects.get(pk=17)
- self.assertEqual(obj.fld, 18)
- except Mod.DoesNotExist:
- self.fail("transaction with raw sql not committed")
+ self.assertEqual(Mod.objects.count(), 1)
+ # Check that the record is in the DB
+ obj = Mod.objects.all()[0]
+ self.assertEqual(obj.fld, 18)
def test_commit_manually_enforced(self):
"""
@@ -115,19 +113,16 @@ class TestTransactionClosing(TransactionTestCase):
be committed.
"""
cursor = connection.cursor()
- cursor.execute("INSERT into transactions_regress_mod (id,fld) values (1,2)")
+ cursor.execute("INSERT into transactions_regress_mod (fld) values (2)")
transaction.rollback()
- cursor.execute("INSERT into transactions_regress_mod (id,fld) values (1,2)")
+ cursor.execute("INSERT into transactions_regress_mod (fld) values (2)")
reuse_cursor_ref()
# Rollback so that if the decorator didn't commit, the record is unwritten
transaction.rollback()
- try:
- # Check that the record is in the DB
- obj = Mod.objects.get(pk=1)
- self.assertEqual(obj.fld, 2)
- except Mod.DoesNotExist:
- self.fail("After ending a transaction, cursor use no longer sets dirty")
+ self.assertEqual(Mod.objects.count(), 1)
+ obj = Mod.objects.all()[0]
+ self.assertEqual(obj.fld, 2)
def test_failing_query_transaction_closed(self):
"""