summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2012-07-02 15:35:59 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2012-07-03 10:22:13 +0300
commit925a6936b94c74b2e67d90da1fcf2e19efc335cf (patch)
treed2106021c54c9d8afcd9988e332e10fe46686fef
parent784d0c261c76535dc760bc8d76793d92f35c1513 (diff)
Stylistic cleanup of Postgres autocommit tests
Cleaned up tests introduced in f572ee0c65ec5eac9edb0cb3e35c96ec86d89ffb. Thanks to Claude Paroz for suggesting the changes.
-rw-r--r--tests/regressiontests/transactions_regress/tests.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/tests/regressiontests/transactions_regress/tests.py b/tests/regressiontests/transactions_regress/tests.py
index fb26138eed..90b3df03d4 100644
--- a/tests/regressiontests/transactions_regress/tests.py
+++ b/tests/regressiontests/transactions_regress/tests.py
@@ -175,6 +175,8 @@ class TestTransactionClosing(TransactionTestCase):
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
@@ -196,6 +198,9 @@ class TestPostgresAutocommit(TransactionTestCase):
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)
@@ -222,14 +227,6 @@ class TestPostgresAutocommit(TransactionTestCase):
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):