diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-18 10:59:10 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-18 11:02:28 +0200 |
| commit | c03cf0b096c241d9b8c83d775355625d2d8a8e86 (patch) | |
| tree | 7e49f113939f0af56cbfe7e8c45966e20a07f98c | |
| parent | 4c1286cf78d03fb7df03774f5f4beb9756ec29c0 (diff) | |
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.
| -rw-r--r-- | tests/regressiontests/backends/tests.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py index a6425c5591..dc92189344 100644 --- a/tests/regressiontests/backends/tests.py +++ b/tests/regressiontests/backends/tests.py @@ -584,7 +584,7 @@ class ThreadTests(TestCase): 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 @@ class ThreadTests(TestCase): 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): """ |
