Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated a test that doesn't make sense with autocommit.

  • Loading branch information...
commit 0cee3c0e43e20ca91aca18210c0b813c42407b1b 1 parent 423c0d5
@aaugustin aaugustin authored
Showing with 15 additions and 13 deletions.
  1. +15 −13 tests/transactions_regress/tests.py
View
28 tests/transactions_regress/tests.py
@@ -4,7 +4,7 @@
from django.db.transaction import commit_on_success, commit_manually, TransactionManagementError
from django.test import TransactionTestCase, skipUnlessDBFeature
from django.test.utils import override_settings
-from django.utils.unittest import skipIf, skipUnless, expectedFailure
+from django.utils.unittest import skipIf, skipUnless
from transactions.tests import IgnorePendingDeprecationWarningsMixin
@@ -187,22 +187,24 @@ def tearDown(self):
connections[DEFAULT_DB_ALIAS].close()
connections[DEFAULT_DB_ALIAS] = self._old_backend
- # TODO: update this test to account for database-level autocommit.
- @expectedFailure
def test_commit(self):
"""
Users are allowed to commit and rollback connections.
"""
- # The starting value is False, not None.
- self.assertIs(connection._dirty, False)
- list(Mod.objects.all())
- self.assertTrue(connection.is_dirty())
- connection.commit()
- self.assertFalse(connection.is_dirty())
- list(Mod.objects.all())
- self.assertTrue(connection.is_dirty())
- connection.rollback()
- self.assertFalse(connection.is_dirty())
+ connection.set_autocommit(False)
+ try:
+ # The starting value is False, not None.
+ self.assertIs(connection._dirty, False)
+ list(Mod.objects.all())
+ self.assertTrue(connection.is_dirty())
+ connection.commit()
+ self.assertFalse(connection.is_dirty())
+ list(Mod.objects.all())
+ self.assertTrue(connection.is_dirty())
+ connection.rollback()
+ self.assertFalse(connection.is_dirty())
+ finally:
+ connection.set_autocommit(True)
def test_enter_exit_management(self):
orig_dirty = connection._dirty

0 comments on commit 0cee3c0

Please sign in to comment.
Something went wrong with that request. Please try again.