1
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
1
# Copyright (C) 2006, 2007, 2009, 2010, 2011 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
23
from bzrlib.tests.blackbox import ExternalBase
24
from bzrlib.config import (ensure_config_dir_exists, config_filename)
27
class TestHelp(ExternalBase):
28
from bzrlib.tests.test_i18n import ZzzTranslations
31
class TestHelp(tests.TestCaseWithTransport):
29
33
def test_help_basic(self):
30
34
for cmd in ['--help', 'help', '-h', '-?']:
104
108
self.assertEquals(dash_help, qmark_long)
105
109
self.assertEquals(dash_help, qmark_cmds)
111
def test_help_width_zero(self):
112
self.overrideEnv('BZR_COLUMNS', '0')
113
self.run_bzr('help commands')
107
115
def test_hidden(self):
108
116
help_commands = self.run_bzr('help commands')[0]
109
117
help_hidden = self.run_bzr('help hidden-commands')[0]
161
169
def test_help_with_aliases(self):
162
170
original = self.run_bzr('help cat')[0]
164
ensure_config_dir_exists()
165
CONFIG=("[ALIASES]\n"
169
open(config_filename(),'wb').write(CONFIG)
172
conf = config.GlobalConfig.from_string('''[ALIASES]
171
177
expected = original + "'bzr cat' is an alias for 'bzr cat'.\n"
172
178
self.assertEqual(expected, self.run_bzr('help cat')[0])
174
180
self.assertEqual("'bzr c' is an alias for 'bzr cat'.\n",
175
181
self.run_bzr('help c')[0])
184
class TestTranslatedHelp(tests.TestCaseWithTransport):
185
"""Tests for display of translated help topics"""
188
super(TestTranslatedHelp, self).setUp()
189
self.overrideAttr(i18n, '_translations', ZzzTranslations())
191
def test_help_command_utf8(self):
192
out, err = self.run_bzr(["help", "push"], encoding="utf-8")
193
self.assertContainsRe(out, "zz\xc3\xa5{{:See also:")
195
def test_help_switch_utf8(self):
196
out, err = self.run_bzr(["push", "--help"], encoding="utf-8")
197
self.assertContainsRe(out, "zz\xc3\xa5{{:See also:")
199
def test_help_command_ascii(self):
200
out, err = self.run_bzr(["help", "push"], encoding="ascii")
201
self.assertContainsRe(out, "zz\\?{{:See also:")
203
def test_help_switch_ascii(self):
204
out, err = self.run_bzr(["push", "--help"], encoding="ascii")
205
self.assertContainsRe(out, "zz\\?{{:See also:")