Ticket #16047: 1-autocommit-tests.patch

File 1-autocommit-tests.patch, 1.5 KB (added by Brodie Rao, 13 years ago)
  • tests/modeltests/transactions/tests.py

    # HG changeset patch
    # User Brodie Rao <brodie@bitheap.org>
    # Date 1305680828 25200
    # Branch releases/1.3.X
    # Node ID 6709ee4d9f37ada03979e5bd1d7b1fc737eef936
    # Parent  0ea817ff93c438044844c20b1a70ceb5c6f183f2
    transaction tests: add tests for confirming autocommit/isolation level changes
    
    diff --git a/tests/modeltests/transactions/tests.py b/tests/modeltests/transactions/tests.py
    a b class TransactionTests(TransactionTestCa  
    165165            using_manually_managed_mistake
    166166        )
    167167
     168    @skipUnlessDBFeature('supports_transactions')
     169    def test_autocommit_enabled(self):
     170        """
     171        Confirm that the default isolation level matches the
     172        autocommit setting.
     173        """
     174        self.assertEqual(connection.isolation_level, int(not connection.features.uses_autocommit))
     175
     176    @skipUnlessDBFeature('supports_transactions')
     177    def test_autocommit_restored(self):
     178        """
     179        If autocommit is enabled, the isolation level should return to
     180        autocommit when leaving transaction management.
     181        """
     182
     183        # The above transaction decorators do this same sort of dance.
     184        transaction.enter_transaction_management()
     185        transaction.managed(True)
     186        transaction.leave_transaction_management()
     187        self.assertEqual(connection.isolation_level, int(not connection.features.uses_autocommit))
     188
    168189
    169190class TransactionRollbackTests(TransactionTestCase):
    170191    def execute_bad_sql(self):
Back to Top