Browse Source

[2353] Use assertRaises() instead of the excessive code

Mukund Sivaraman 12 years ago
parent
commit
f1035ba18d
1 changed files with 3 additions and 8 deletions
  1. 3 8
      src/bin/bind10/tests/bind10_test.py.in

+ 3 - 8
src/bin/bind10/tests/bind10_test.py.in

@@ -1619,16 +1619,11 @@ class TestBossComponents(unittest.TestCase):
             return tmp_time()
             return tmp_time()
         time.time = _my_time
         time.time = _my_time
 
 
-        thrown = False
-        # An exception will be thrown here when it eventually times out.
-        try:
+        with self.assertRaises(bind10_src.CChannelConnectError):
+            # An exception will be thrown here when it eventually times
+            # out.
             pi = bob.start_msgq()
             pi = bob.start_msgq()
-        except bind10_src.CChannelConnectError as e:
-            thrown = True
 
 
-        # We just check that an exception was thrown, and that several
-        # attempts were made to connect.
-        self.assertTrue(thrown)
         # 1 second of attempts every 0.1 seconds should result in at
         # 1 second of attempts every 0.1 seconds should result in at
         # least 5 attempts
         # least 5 attempts
         self.assertGreater(attempts, 5)
         self.assertGreater(attempts, 5)