Rev 6490: (gz) Default help output to ui wrapped stream rather than raw stdout for in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/2.5/

Patch Queue Manager pqm at pqm.ubuntu.com
Mon Mar 12 18:06:48 UTC 2012


At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/2.5/

------------------------------------------------------------
revno: 6490 [merge]
revision-id: pqm at pqm.ubuntu.com-20120312180647-mkadzywe7jc178lr
parent: pqm at pqm.ubuntu.com-20120312155848-3o1y62ffilhls4bf
parent: martin.packman at canonical.com-20120227121628-9q8krey0u73v56k3
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.5
timestamp: Mon 2012-03-12 18:06:47 +0000
message:
  (gz) Default help output to ui wrapped stream rather than raw stdout for
   better encoding handling (Martin Packman)
modified:
  bzrlib/help.py                 help.py-20050505025907-4dd7a6d63912f894
  bzrlib/tests/blackbox/test_help.py test_help.py-20060216004358-4ee8a2a338f75a62
=== modified file 'bzrlib/help.py'
--- a/bzrlib/help.py	2011-12-18 15:28:38 +0000
+++ b/bzrlib/help.py	2012-02-27 12:16:28 +0000
@@ -31,6 +31,7 @@
     help_topics,
     osutils,
     plugin,
+    ui,
     utextwrap,
     )
 
@@ -38,7 +39,7 @@
 def help(topic=None, outfile=None):
     """Write the help for the specific topic to outfile"""
     if outfile is None:
-        outfile = sys.stdout
+        outfile = ui.ui_factory.make_output_stream()
 
     indices = HelpIndices()
 
@@ -63,7 +64,7 @@
 def help_commands(outfile=None):
     """List all commands"""
     if outfile is None:
-        outfile = sys.stdout
+        outfile = ui.ui_factory.make_output_stream()
     outfile.write(_help_commands_to_text('commands'))
 
 

=== modified file 'bzrlib/tests/blackbox/test_help.py'
--- a/bzrlib/tests/blackbox/test_help.py	2011-01-12 00:58:05 +0000
+++ b/bzrlib/tests/blackbox/test_help.py	2012-02-27 12:15:02 +0000
@@ -19,12 +19,16 @@
 """
 
 
-import bzrlib
-from bzrlib import config
-from bzrlib.tests import TestCaseWithTransport
-
-
-class TestHelp(TestCaseWithTransport):
+from bzrlib import (
+    config,
+    i18n,
+    tests,
+    )
+
+from bzrlib.tests.test_i18n import ZzzTranslations
+
+
+class TestHelp(tests.TestCaseWithTransport):
 
     def test_help_basic(self):
         for cmd in ['--help', 'help', '-h', '-?']:
@@ -175,3 +179,27 @@
 
         self.assertEqual("'bzr c' is an alias for 'bzr cat'.\n",
                          self.run_bzr('help c')[0])
+
+
+class TestTranslatedHelp(tests.TestCaseWithTransport):
+    """Tests for display of translated help topics"""
+
+    def setUp(self):
+        super(TestTranslatedHelp, self).setUp()
+        self.overrideAttr(i18n, '_translations', ZzzTranslations())
+
+    def test_help_command_utf8(self):
+        out, err = self.run_bzr(["help", "push"], encoding="utf-8")
+        self.assertContainsRe(out, "zz\xc3\xa5{{:See also:")
+
+    def test_help_switch_utf8(self):
+        out, err = self.run_bzr(["push", "--help"], encoding="utf-8")
+        self.assertContainsRe(out, "zz\xc3\xa5{{:See also:")
+
+    def test_help_command_ascii(self):
+        out, err = self.run_bzr(["help", "push"], encoding="ascii")
+        self.assertContainsRe(out, "zz\\?{{:See also:")
+
+    def test_help_switch_ascii(self):
+        out, err = self.run_bzr(["push", "--help"], encoding="ascii")
+        self.assertContainsRe(out, "zz\\?{{:See also:")




More information about the bazaar-commits mailing list