diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-03-02 20:25:25 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-03-11 14:48:53 +0100 |
| commit | 7aacde84f2b499d9c35741cbfccb621af6b48903 (patch) | |
| tree | 06b20c555a5110a5771ba75c05b7c904a97f8c2e /tests | |
| parent | 9cec689e6a7e299b3416519ee075b2316ecc5a64 (diff) | |
Made transaction.managed a no-op and deprecated it.
enter_transaction_management() was nearly always followed by managed().
In three places it wasn't, but they will all be refactored eventually.
The "forced" keyword argument avoids introducing behavior changes until
then.
This is mostly backwards-compatible, except, of course, for managed
itself. There's a minor difference in _enter_transaction_management:
the top self.transaction_state now contains the new 'managed' state
rather than the previous one. Django doesn't access
self.transaction_state in _enter_transaction_management.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/delete_regress/tests.py | 4 | ||||
| -rw-r--r-- | tests/middleware/tests.py | 6 | ||||
| -rw-r--r-- | tests/requests/tests.py | 2 | ||||
| -rw-r--r-- | tests/select_for_update/tests.py | 3 | ||||
| -rw-r--r-- | tests/serializers/tests.py | 1 | ||||
| -rw-r--r-- | tests/transactions_regress/tests.py | 5 |
6 files changed, 2 insertions, 19 deletions
diff --git a/tests/delete_regress/tests.py b/tests/delete_regress/tests.py index 9fcc19ba71..e88c95e229 100644 --- a/tests/delete_regress/tests.py +++ b/tests/delete_regress/tests.py @@ -22,9 +22,7 @@ class DeleteLockingTest(TransactionTestCase): self.conn2 = new_connections[DEFAULT_DB_ALIAS] # Put both DB connections into managed transaction mode transaction.enter_transaction_management() - transaction.managed(True) self.conn2.enter_transaction_management() - self.conn2.managed(True) def tearDown(self): # Close down the second connection. @@ -335,7 +333,7 @@ class Ticket19102Tests(TestCase): ).select_related('orgunit').delete() self.assertFalse(Login.objects.filter(pk=self.l1.pk).exists()) self.assertTrue(Login.objects.filter(pk=self.l2.pk).exists()) - + @skipUnlessDBFeature("update_can_self_select") def test_ticket_19102_defer(self): with self.assertNumQueries(1): diff --git a/tests/middleware/tests.py b/tests/middleware/tests.py index 4e5fd8ea6b..122371c02c 100644 --- a/tests/middleware/tests.py +++ b/tests/middleware/tests.py @@ -692,7 +692,6 @@ class TransactionMiddlewareTest(TransactionTestCase): def test_managed_response(self): transaction.enter_transaction_management() - transaction.managed(True) Band.objects.create(name='The Beatles') self.assertTrue(transaction.is_dirty()) TransactionMiddleware().process_response(self.request, self.response) @@ -700,8 +699,7 @@ class TransactionMiddlewareTest(TransactionTestCase): self.assertEqual(Band.objects.count(), 1) def test_unmanaged_response(self): - transaction.enter_transaction_management() - transaction.managed(False) + transaction.enter_transaction_management(False) self.assertEqual(Band.objects.count(), 0) TransactionMiddleware().process_response(self.request, self.response) self.assertFalse(transaction.is_managed()) @@ -711,7 +709,6 @@ class TransactionMiddlewareTest(TransactionTestCase): def test_exception(self): transaction.enter_transaction_management() - transaction.managed(True) Band.objects.create(name='The Beatles') self.assertTrue(transaction.is_dirty()) TransactionMiddleware().process_exception(self.request, None) @@ -726,7 +723,6 @@ class TransactionMiddlewareTest(TransactionTestCase): raise IntegrityError() connections[DEFAULT_DB_ALIAS].commit = raise_exception transaction.enter_transaction_management() - transaction.managed(True) Band.objects.create(name='The Beatles') self.assertTrue(transaction.is_dirty()) with self.assertRaises(IntegrityError): diff --git a/tests/requests/tests.py b/tests/requests/tests.py index 4fdc17618b..2803d7995b 100644 --- a/tests/requests/tests.py +++ b/tests/requests/tests.py @@ -576,7 +576,6 @@ class DatabaseConnectionHandlingTests(TransactionTestCase): # Make sure there is an open connection connection.cursor() connection.enter_transaction_management() - connection.managed(True) signals.request_finished.send(sender=response._handler_class) self.assertEqual(len(connection.transaction_state), 0) @@ -585,7 +584,6 @@ class DatabaseConnectionHandlingTests(TransactionTestCase): connection.settings_dict['CONN_MAX_AGE'] = 0 connection.enter_transaction_management() - connection.managed(True) connection.set_dirty() # Test that the rollback doesn't succeed (for example network failure # could cause this). diff --git a/tests/select_for_update/tests.py b/tests/select_for_update/tests.py index b9716bd797..c2fa22705a 100644 --- a/tests/select_for_update/tests.py +++ b/tests/select_for_update/tests.py @@ -25,7 +25,6 @@ class SelectForUpdateTests(TransactionTestCase): def setUp(self): transaction.enter_transaction_management() - transaction.managed(True) self.person = Person.objects.create(name='Reinhardt') # We have to commit here so that code in run_select_for_update can @@ -37,7 +36,6 @@ class SelectForUpdateTests(TransactionTestCase): new_connections = ConnectionHandler(settings.DATABASES) self.new_connection = new_connections[DEFAULT_DB_ALIAS] self.new_connection.enter_transaction_management() - self.new_connection.managed(True) # We need to set settings.DEBUG to True so we can capture # the output SQL to examine. @@ -162,7 +160,6 @@ class SelectForUpdateTests(TransactionTestCase): # We need to enter transaction management again, as this is done on # per-thread basis transaction.enter_transaction_management() - transaction.managed(True) people = list( Person.objects.all().select_for_update(nowait=nowait) ) diff --git a/tests/serializers/tests.py b/tests/serializers/tests.py index 34d0f5f1b1..a96a1af748 100644 --- a/tests/serializers/tests.py +++ b/tests/serializers/tests.py @@ -268,7 +268,6 @@ class SerializersTransactionTestBase(object): # within a transaction in order to test forward reference # handling. transaction.enter_transaction_management() - transaction.managed(True) objs = serializers.deserialize(self.serializer_name, self.fwd_ref_str) with connection.constraint_checks_disabled(): for obj in objs: diff --git a/tests/transactions_regress/tests.py b/tests/transactions_regress/tests.py index 6ba04892cd..0af7605339 100644 --- a/tests/transactions_regress/tests.py +++ b/tests/transactions_regress/tests.py @@ -223,7 +223,6 @@ class TestNewConnection(TransactionTestCase): def test_commit_unless_managed_in_managed(self): cursor = connection.cursor() connection.enter_transaction_management() - transaction.managed(True) cursor.execute("INSERT into transactions_regress_mod (fld) values (2)") connection.commit_unless_managed() self.assertTrue(connection.is_dirty()) @@ -280,7 +279,6 @@ class TestPostgresAutocommitAndIsolation(TransactionTestCase): def test_transaction_management(self): transaction.enter_transaction_management() - transaction.managed(True) self.assertEqual(connection.isolation_level, self._serializable) transaction.leave_transaction_management() @@ -288,7 +286,6 @@ class TestPostgresAutocommitAndIsolation(TransactionTestCase): def test_transaction_stacking(self): transaction.enter_transaction_management() - transaction.managed(True) self.assertEqual(connection.isolation_level, self._serializable) transaction.enter_transaction_management() @@ -302,13 +299,11 @@ class TestPostgresAutocommitAndIsolation(TransactionTestCase): def test_enter_autocommit(self): transaction.enter_transaction_management() - transaction.managed(True) self.assertEqual(connection.isolation_level, self._serializable) list(Mod.objects.all()) self.assertTrue(transaction.is_dirty()) # Enter autocommit mode again. transaction.enter_transaction_management(False) - transaction.managed(False) self.assertFalse(transaction.is_dirty()) self.assertEqual( connection.connection.get_transaction_status(), |
