Some style fixes for stuff that was clearly brough tover from doctests.

This commit is contained in:
Alex Gaynor 2013-02-23 13:04:08 -08:00
parent cf890c110e
commit 150e202172
2 changed files with 10 additions and 7 deletions

View File

@ -1,10 +1,13 @@
from django.db import models from django.db import models
class Mod(models.Model): class Mod(models.Model):
fld = models.IntegerField() fld = models.IntegerField()
class M2mA(models.Model): class M2mA(models.Model):
others = models.ManyToManyField('M2mB') others = models.ManyToManyField('M2mB')
class M2mB(models.Model): class M2mB(models.Model):
fld = models.IntegerField() fld = models.IntegerField()

View File

@ -42,7 +42,7 @@ class TestTransactionClosing(TransactionTestCase):
@commit_manually @commit_manually
def non_comitter(): def non_comitter():
"Execute a managed transaction with read-only operations and fail to commit" "Execute a managed transaction with read-only operations and fail to commit"
_ = Mod.objects.count() Mod.objects.count()
self.assertRaises(TransactionManagementError, non_comitter) self.assertRaises(TransactionManagementError, non_comitter)
@ -56,7 +56,7 @@ class TestTransactionClosing(TransactionTestCase):
""" """
Perform a database query, then commit the transaction Perform a database query, then commit the transaction
""" """
_ = Mod.objects.count() Mod.objects.count()
transaction.commit() transaction.commit()
try: try:
@ -74,7 +74,7 @@ class TestTransactionClosing(TransactionTestCase):
""" """
Perform a database query, then rollback the transaction Perform a database query, then rollback the transaction
""" """
_ = Mod.objects.count() Mod.objects.count()
transaction.rollback() transaction.rollback()
try: try:
@ -90,9 +90,9 @@ class TestTransactionClosing(TransactionTestCase):
@commit_manually @commit_manually
def fake_committer(): def fake_committer():
"Query, commit, then query again, leaving with a pending transaction" "Query, commit, then query again, leaving with a pending transaction"
_ = Mod.objects.count() Mod.objects.count()
transaction.commit() transaction.commit()
_ = Mod.objects.count() Mod.objects.count()
self.assertRaises(TransactionManagementError, fake_committer) self.assertRaises(TransactionManagementError, fake_committer)
@ -239,7 +239,7 @@ class SavepointTest(TransactionTestCase):
mod = Mod.objects.create(fld=1) mod = Mod.objects.create(fld=1)
pk = mod.pk pk = mod.pk
sid = transaction.savepoint() sid = transaction.savepoint()
mod1 = Mod.objects.filter(pk=pk).update(fld=10) Mod.objects.filter(pk=pk).update(fld=10)
transaction.savepoint_commit(sid) transaction.savepoint_commit(sid)
mod2 = Mod.objects.get(pk=pk) mod2 = Mod.objects.get(pk=pk)
transaction.commit() transaction.commit()
@ -257,7 +257,7 @@ class SavepointTest(TransactionTestCase):
mod = Mod.objects.create(fld=1) mod = Mod.objects.create(fld=1)
pk = mod.pk pk = mod.pk
sid = transaction.savepoint() sid = transaction.savepoint()
mod1 = Mod.objects.filter(pk=pk).update(fld=20) Mod.objects.filter(pk=pk).update(fld=20)
transaction.savepoint_rollback(sid) transaction.savepoint_rollback(sid)
mod2 = Mod.objects.get(pk=pk) mod2 = Mod.objects.get(pk=pk)
transaction.commit() transaction.commit()