summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2013-02-12 23:11:22 +0200
committerAnssi Kääriäinen <akaariai@gmail.com>2013-02-13 00:39:43 +0200
commitdec7dd99f095f938bc4306a0260d5b131935ad82 (patch)
treed6452d410c13c0b65fd4837048dd4c923f4d104b /tests
parentb4fb448f8387d92832fc70ac58de69c73d5f1729 (diff)
[1.4.x] Removed try-except in django.db.close_connection()
The reason was that the except clause needed to remove a connection from the django.db.connections dict, but other parts of Django do not expect this to happen. In addition the except clause was silently swallowing the exception messages. Refs #19707, special thanks to Carl Meyer for pointing out that this approach should be taken.
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/requests/tests.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/regressiontests/requests/tests.py b/tests/regressiontests/requests/tests.py
index aba0461c79..5927cbb8bc 100644
--- a/tests/regressiontests/requests/tests.py
+++ b/tests/regressiontests/requests/tests.py
@@ -559,9 +559,14 @@ class TransactionRequestTests(TransactionTestCase):
def fail_horribly():
raise Exception("Horrible failure!")
conn._rollback = fail_horribly
+ try:
+ with self.assertRaises(Exception):
+ signals.request_finished.send(sender=self.__class__)
+ # The connection's state wasn't cleaned up
+ self.assertTrue(len(connection.transaction_state), 1)
+ finally:
+ del conn._rollback
+ # The connection will be cleaned on next request where the conn
+ # works again.
signals.request_finished.send(sender=self.__class__)
- # As even rollback wasn't possible the connection wrapper itself was
- # abandoned. Accessing the connections[alias] will create a new
- # connection wrapper, whch must be different than the original one.
- self.assertIsNot(conn, connections[DEFAULT_DB_ALIAS])
self.assertEqual(len(connection.transaction_state), 0)