Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleaned up a test slightly.

We should catch all exceptions in the thread to ensure it doesn't die
with an unhandled exception. The type of the exception is already
checked further in the test.
  • Loading branch information...
commit c03cf0b096c241d9b8c83d775355625d2d8a8e86 1 parent 4c1286c
@aaugustin aaugustin authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 tests/regressiontests/backends/tests.py
View
8 tests/regressiontests/backends/tests.py
@@ -584,7 +584,7 @@ def runner(main_thread_connection):
connections['default'] = main_thread_connection
try:
models.Person.objects.get(first_name="John", last_name="Doe")
- except DatabaseError as e:
+ except Exception as e:
exceptions.append(e)
t = threading.Thread(target=runner, args=[connections['default']])
t.start()
@@ -594,21 +594,21 @@ def runner(main_thread_connection):
exceptions = []
do_thread()
# Forbidden!
- self.assertTrue(isinstance(exceptions[0], DatabaseError))
+ self.assertIsInstance(exceptions[0], DatabaseError)
# If explicitly setting allow_thread_sharing to False
connections['default'].allow_thread_sharing = False
exceptions = []
do_thread()
# Forbidden!
- self.assertTrue(isinstance(exceptions[0], DatabaseError))
+ self.assertIsInstance(exceptions[0], DatabaseError)
# If explicitly setting allow_thread_sharing to True
connections['default'].allow_thread_sharing = True
exceptions = []
do_thread()
# All good
- self.assertEqual(len(exceptions), 0)
+ self.assertEqual(exceptions, [])
def test_closing_non_shared_connections(self):
"""

0 comments on commit c03cf0b

Please sign in to comment.
Something went wrong with that request. Please try again.