Used skip(If|Unless)DBFeature in transactions tests.

This commit is contained in:
Jon Dufresne 2018-10-04 07:09:06 -07:00 committed by Tim Graham
parent 9f6d0c11eb
commit 5a23a285de
1 changed files with 5 additions and 11 deletions

View File

@ -14,7 +14,7 @@ from django.test import (
from .models import Reporter from .models import Reporter
@skipUnless(connection.features.uses_savepoints, "'atomic' requires transactions and savepoints.") @skipUnlessDBFeature('uses_savepoints')
class AtomicTests(TransactionTestCase): class AtomicTests(TransactionTestCase):
""" """
Tests for the atomic decorator and context manager. Tests for the atomic decorator and context manager.
@ -228,10 +228,7 @@ class AtomicInsideTransactionTests(AtomicTests):
self.atomic.__exit__(*sys.exc_info()) self.atomic.__exit__(*sys.exc_info())
@skipIf( @skipIfDBFeature('autocommits_when_autocommit_is_off')
connection.features.autocommits_when_autocommit_is_off,
"This test requires a non-autocommit mode that doesn't autocommit."
)
class AtomicWithoutAutocommitTests(AtomicTests): class AtomicWithoutAutocommitTests(AtomicTests):
"""All basic tests for atomic should also pass when autocommit is turned off.""" """All basic tests for atomic should also pass when autocommit is turned off."""
@ -245,7 +242,7 @@ class AtomicWithoutAutocommitTests(AtomicTests):
transaction.set_autocommit(True) transaction.set_autocommit(True)
@skipUnless(connection.features.uses_savepoints, "'atomic' requires transactions and savepoints.") @skipUnlessDBFeature('uses_savepoints')
class AtomicMergeTests(TransactionTestCase): class AtomicMergeTests(TransactionTestCase):
"""Test merging transactions with savepoint=False.""" """Test merging transactions with savepoint=False."""
@ -295,7 +292,7 @@ class AtomicMergeTests(TransactionTestCase):
self.assertQuerysetEqual(Reporter.objects.all(), ['<Reporter: Tintin>']) self.assertQuerysetEqual(Reporter.objects.all(), ['<Reporter: Tintin>'])
@skipUnless(connection.features.uses_savepoints, "'atomic' requires transactions and savepoints.") @skipUnlessDBFeature('uses_savepoints')
class AtomicErrorsTests(TransactionTestCase): class AtomicErrorsTests(TransactionTestCase):
available_apps = ['transactions'] available_apps = ['transactions']
@ -437,10 +434,7 @@ class AtomicMiscTests(TransactionTestCase):
connection.savepoint_rollback(sid) connection.savepoint_rollback(sid)
@skipIf( @skipIfDBFeature('autocommits_when_autocommit_is_off')
connection.features.autocommits_when_autocommit_is_off,
"This test requires a non-autocommit mode that doesn't autocommit."
)
class NonAutocommitTests(TransactionTestCase): class NonAutocommitTests(TransactionTestCase):
available_apps = [] available_apps = []