Rev 5932: Since the exception is thrown/caught in a thread and the 'listening on port' is emitted by another thread and since synchrozining them is way out of scope for the test, it's easier to just not emit the 'listening' line. So we just tell the server to "Don't do that!". in file:///home/vila/src/bzr/bugs/789167-test-server/

Vincent Ladeuil v.ladeuil+lp at free.fr
Sat May 28 09:33:22 UTC 2011


At file:///home/vila/src/bzr/bugs/789167-test-server/

------------------------------------------------------------
revno: 5932
revision-id: v.ladeuil+lp at free.fr-20110528093321-jhpw0oatzbdsskes
parent: v.ladeuil+lp at free.fr-20110528091036-c82o6sozffi0q6ey
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 789167-test-server
timestamp: Sat 2011-05-28 11:33:21 +0200
message:
  Since the exception is thrown/caught in a thread and the 'listening on port' is emitted by another thread and since synchrozining them is way out of scope for the test, it's easier to just not emit the 'listening' line. So we just tell the server to "Don't do that!".
-------------- next part --------------
=== modified file 'bzrlib/tests/blackbox/test_serve.py'
--- a/bzrlib/tests/blackbox/test_serve.py	2011-05-28 08:40:17 +0000
+++ b/bzrlib/tests/blackbox/test_serve.py	2011-05-28 09:33:21 +0000
@@ -103,12 +103,14 @@
         SmartTCPServer.hooks.install_named_hook(
             'server_exception', hook,
             'test_server_except_hook hook')
-        args = ['--port', 'localhost:0']
+        # We don't want the 'listening on port' line to interfer with the
+        # test. We don't care about when the exception is raised, we care about
+        # catching it. Using '--quiet' ensures we don't get spurious failures
+        # depending on whether the hook is fired before or after the main
+        # server thread get a change to emit the 'listening on port' line.
+        args = ['--port', 'localhost:0', '--quiet']
         out, err = self.run_bzr_serve_then_func(args, retcode=0)
-        err_lines = err.splitlines()
-        self.assertLength(2, err_lines)
-        self.assertStartsWith(err_lines[0],'listening on port:')
-        self.assertEqual('catching exception', err_lines[1])
+        self.assertEqual('catching exception\n', err)
 
     def test_server_exception_no_hook(self):
         """test exception without hook returns error"""



More information about the bazaar-commits mailing list