Skip to content

Commit

Permalink
Stylistic cleanup of Postgres autocommit tests
Browse files Browse the repository at this point in the history
Cleaned up tests introduced in f572ee0.

Thanks to Claude Paroz for suggesting the changes.
  • Loading branch information
akaariai committed Jul 3, 2012
1 parent 784d0c2 commit 925a693
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tests/regressiontests/transactions_regress/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def test_failing_query_transaction_closed_debug(self):
self.test_failing_query_transaction_closed()


@skipUnless(connection.vendor == 'postgresql',
"This test only valid for PostgreSQL")
class TestPostgresAutocommit(TransactionTestCase):
"""
Tests to make sure psycopg2's autocommit mode is restored after entering
Expand All @@ -196,6 +198,9 @@ def setUp(self):
new_backend = self._old_backend.__class__(settings, DEFAULT_DB_ALIAS)
connections[DEFAULT_DB_ALIAS] = new_backend

def tearDown(self):
connections[DEFAULT_DB_ALIAS] = self._old_backend

def test_initial_autocommit_state(self):
self.assertTrue(connection.features.uses_autocommit)
self.assertEqual(connection.isolation_level, self._autocommit)
Expand All @@ -222,14 +227,6 @@ def test_transaction_stacking(self):
transaction.leave_transaction_management()
self.assertEqual(connection.isolation_level, self._autocommit)

def tearDown(self):
connections[DEFAULT_DB_ALIAS] = self._old_backend

TestPostgresAutocommit = skipUnless(connection.vendor == 'postgresql',
"This test only valid for PostgreSQL")(TestPostgresAutocommit)
TestPostgresAutoCommit = skipUnlessDBFeature('supports_transactions')(
TestPostgresAutocommit)


class TestManyToManyAddTransaction(TransactionTestCase):
def test_manyrelated_add_commit(self):
Expand Down

0 comments on commit 925a693

Please sign in to comment.