Stylistic cleanup of Postgres autocommit tests
Cleaned up tests introduced in f572ee0c65
.
Thanks to Claude Paroz for suggesting the changes.
This commit is contained in:
parent
784d0c261c
commit
925a6936b9
|
@ -175,6 +175,8 @@ class TestTransactionClosing(TransactionTestCase):
|
||||||
self.test_failing_query_transaction_closed()
|
self.test_failing_query_transaction_closed()
|
||||||
|
|
||||||
|
|
||||||
|
@skipUnless(connection.vendor == 'postgresql',
|
||||||
|
"This test only valid for PostgreSQL")
|
||||||
class TestPostgresAutocommit(TransactionTestCase):
|
class TestPostgresAutocommit(TransactionTestCase):
|
||||||
"""
|
"""
|
||||||
Tests to make sure psycopg2's autocommit mode is restored after entering
|
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)
|
new_backend = self._old_backend.__class__(settings, DEFAULT_DB_ALIAS)
|
||||||
connections[DEFAULT_DB_ALIAS] = new_backend
|
connections[DEFAULT_DB_ALIAS] = new_backend
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
connections[DEFAULT_DB_ALIAS] = self._old_backend
|
||||||
|
|
||||||
def test_initial_autocommit_state(self):
|
def test_initial_autocommit_state(self):
|
||||||
self.assertTrue(connection.features.uses_autocommit)
|
self.assertTrue(connection.features.uses_autocommit)
|
||||||
self.assertEqual(connection.isolation_level, self._autocommit)
|
self.assertEqual(connection.isolation_level, self._autocommit)
|
||||||
|
@ -222,14 +227,6 @@ class TestPostgresAutocommit(TransactionTestCase):
|
||||||
transaction.leave_transaction_management()
|
transaction.leave_transaction_management()
|
||||||
self.assertEqual(connection.isolation_level, self._autocommit)
|
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):
|
class TestManyToManyAddTransaction(TransactionTestCase):
|
||||||
def test_manyrelated_add_commit(self):
|
def test_manyrelated_add_commit(self):
|
||||||
|
|
Loading…
Reference in New Issue