Rev 4961: (vila) Fix brittle test in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jan 14 18:13:01 GMT 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4961 [merge]
revision-id: pqm at pqm.ubuntu.com-20100114181258-ey8bgiolululzosu
parent: pqm at pqm.ubuntu.com-20100114003343-62hs2asyy61hsww1
parent: v.ladeuil+lp at free.fr-20100114164104-uwvhmf7fowi1lzmg
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-01-14 18:12:58 +0000
message:
  (vila) Fix brittle test
modified:
  bzrlib/tests/blackbox/test_help.py test_help.py-20060216004358-4ee8a2a338f75a62
=== modified file 'bzrlib/tests/blackbox/test_help.py'
--- a/bzrlib/tests/blackbox/test_help.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_help.py	2010-01-14 16:41:04 +0000
@@ -105,8 +105,23 @@
         self.assertEquals(dash_help, qmark_cmds)
 
     def test_hidden(self):
-        commands = self.run_bzr('help commands')[0]
-        hidden = self.run_bzr('help hidden-commands')[0]
+        help_commands = self.run_bzr('help commands')[0]
+        help_hidden = self.run_bzr('help hidden-commands')[0]
+
+        def extract_cmd_names(help_output):
+            # keep only the command names to avoid matching on help text (there
+            # is a high risk to fail a test when a plugin get installed
+            # otherwise)
+            cmds = []
+            for line in help_output.split('\n'):
+                if line.startswith(' '):
+                    continue # help on more than one line
+                cmd = line.split(' ')[0]
+                if line:
+                    cmds.append(cmd)
+            return cmds
+        commands = extract_cmd_names(help_commands)
+        hidden = extract_cmd_names(help_hidden)
         self.assertTrue('commit' in commands)
         self.assertTrue('commit' not in hidden)
         self.assertTrue('rocks' in hidden)




More information about the bazaar-commits mailing list