~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/codehosting/tests/test_lpserve.py

  • Committer: Gary Poster
  • Date: 2009-10-16 01:54:41 UTC
  • mto: This revision was merged to the branch mainline in revision 9721.
  • Revision ID: gary.poster@canonical.com-20091016015441-sf29c234t3g1i07t
fix a variety of tests found by running this branch in karmic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
__metaclass__ = type
7
7
 
8
8
import os
 
9
import re
9
10
from subprocess import PIPE
10
11
import unittest
11
12
 
30
31
 
31
32
    def assertFinishedCleanly(self, result):
32
33
        """Assert that a server process finished cleanly."""
33
 
        self.assertEqual((0, '', ''), tuple(result))
 
34
        # XXX gary 2009-10-15 bug 316192
 
35
        # Ideally, this method would only be this single line:
 
36
        #
 
37
        # self.assertEqual((0, '', ''), tuple(result))
 
38
        #
 
39
        # However, because of the bug above, stderr (the last value) can
 
40
        # include complaints that bzr tried to import certain plugins but
 
41
        # was unable to.  This can make the last value into something like
 
42
        # this (concatenate the strings):
 
43
        #
 
44
        #  "No module named dbus.bus\n"
 
45
        #  "Unable to load plugin 'dbus' from "
 
46
        #    "'/usr/lib/python2.4/site-packages/bzrlib/plugins'\n"
 
47
        #  "No module named dbus.bus\n"
 
48
        #  "Unable to load plugin 'avahi' from "
 
49
        #    "'/usr/lib/python2.4/site-packages/bzrlib/plugins'\n"
 
50
        #
 
51
        # Therefore, for now, we allow stderr to have messages like
 
52
        # that, with a regex.  A fix for the bzr bug mentioned above has
 
53
        # already been released, so hopefully soon this method can
 
54
        # return to the single assert above, this module will no longer
 
55
        # have to import re, and this comment can be consigned to
 
56
        # history.
 
57
        self.assertEqual(0, result[0]) # the return code
 
58
        self.assertEqual('', result[1]) # stdout
 
59
        self.failUnless(re.match(
 
60
            r"(No module named \S+\n|"
 
61
               "Unable to load plugin \S+ from '/usr/lib/python[^']+'\n)*$",
 
62
            result[2]))
34
63
 
35
64
    def get_python_path(self):
36
65
        """Return the path to the Python interpreter."""