← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~benji/launchpad/bug-972456 into lp:launchpad

 

Benji York has proposed merging lp:~benji/launchpad/bug-972456 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #972456 in Launchpad itself: "Tests can fail when bzr emits an unexpected "unsupported locale setting" warning"
  https://bugs.launchpad.net/launchpad/+bug/972456

For more details, see:
https://code.launchpad.net/~benji/launchpad/bug-972456/+merge/100645

Bug 972456 is about several test failures that occur when bzr warns
about a badly configured locale.

The problem is that _start_subprocess in
bzrplugins/lpserve/test_lpserve.py assumes that the first line of output
(on stderr) will be the "Listening on socket:" line.  When bzr issues
warnings they come before that line so the subsequent assertEqual fails.

To fix this I just keep reading lines of output until we see the
"Listening" line and then proceed.

Lint: the "make lint" report is clean.

QA: this is a test fix only, so no QA step.

-- 
https://code.launchpad.net/~benji/launchpad/bug-972456/+merge/100645
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~benji/launchpad/bug-972456 into lp:launchpad.
=== modified file 'bzrplugins/lpserve/test_lpserve.py'
--- bzrplugins/lpserve/test_lpserve.py	2012-03-29 16:31:02 +0000
+++ bzrplugins/lpserve/test_lpserve.py	2012-04-03 16:19:32 +0000
@@ -437,7 +437,14 @@
             env_changes=env_changes)
         trace.mutter('started lp-service subprocess')
         expected = 'Listening on socket: %s\n' % (path,)
-        path_line = proc.stderr.readline()
+        while True:
+            path_line = proc.stderr.readline()
+            # Stop once we have found the path line.
+            if path_line.startswith('Listening on socket:'):
+                break
+            # If the subprocess has finished, there is no more to read.
+            if proc.poll() is not None:
+                break
         trace.mutter(path_line)
         self.assertEqual(expected, path_line)
         return proc