69
75
self.assertContainsRe(out, 'https://')
70
76
self.assertContainsRe(out, 'sftp://')
78
def test_help_repositories(self):
79
"""Smoke test for 'bzr help repositories'"""
80
out, err = self.run_bzr('help repositories')
81
from bzrlib.help_topics import help_as_plain_text, _repositories
82
expected = help_as_plain_text(_repositories)
83
self.assertEqual(expected, out)
85
def test_help_working_trees(self):
86
"""Smoke test for 'bzr help working-trees'"""
87
out, err = self.run_bzr('help working-trees')
88
from bzrlib.help_topics import help_as_plain_text, _working_trees
89
expected = help_as_plain_text(_working_trees)
90
self.assertEqual(expected, out)
92
def test_help_status_flags(self):
93
"""Smoke test for 'bzr help status-flags'"""
94
out, err = self.run_bzr('help status-flags')
95
from bzrlib.help_topics import help_as_plain_text, _status_flags
96
expected = help_as_plain_text(_status_flags)
97
self.assertEqual(expected, out)
72
99
def test_help_commands(self):
73
dash_help = self.runbzr('--help commands')[0]
74
commands = self.runbzr('help commands')[0]
75
hidden = self.runbzr('help hidden-commands')[0]
76
long_help = self.runbzr('help --long')[0]
77
qmark_long = self.runbzr('? --long')[0]
78
qmark_cmds = self.runbzr('? commands')[0]
100
dash_help = self.run_bzr('--help commands')[0]
101
commands = self.run_bzr('help commands')[0]
102
hidden = self.run_bzr('help hidden-commands')[0]
103
long_help = self.run_bzr('help --long')[0]
104
qmark_long = self.run_bzr('? --long')[0]
105
qmark_cmds = self.run_bzr('? commands')[0]
79
106
self.assertEquals(dash_help, commands)
80
107
self.assertEquals(dash_help, long_help)
81
108
self.assertEquals(dash_help, qmark_long)
82
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')
84
115
def test_hidden(self):
85
commands = self.runbzr('help commands')[0]
86
hidden = self.runbzr('help hidden-commands')[0]
116
help_commands = self.run_bzr('help commands')[0]
117
help_hidden = self.run_bzr('help hidden-commands')[0]
119
def extract_cmd_names(help_output):
120
# keep only the command names to avoid matching on help text (there
121
# is a high risk to fail a test when a plugin get installed
124
for line in help_output.split('\n'):
125
if line.startswith(' '):
126
continue # help on more than one line
127
cmd = line.split(' ')[0]
131
commands = extract_cmd_names(help_commands)
132
hidden = extract_cmd_names(help_hidden)
87
133
self.assertTrue('commit' in commands)
88
134
self.assertTrue('commit' not in hidden)
89
135
self.assertTrue('rocks' in hidden)
90
136
self.assertTrue('rocks' not in commands)
92
138
def test_help_detail(self):
93
dash_h = self.runbzr('commit -h')[0]
94
help_x = self.runbzr('help commit')[0]
95
qmark_x = self.runbzr('help commit')[0]
139
dash_h = self.run_bzr('diff -h')[0]
140
help_x = self.run_bzr('help diff')[0]
96
141
self.assertEquals(dash_h, help_x)
97
self.assertEquals(dash_h, qmark_x)
142
self.assertContainsRe(help_x, "Purpose:")
143
self.assertContainsRe(help_x, "Usage:")
144
self.assertContainsRe(help_x, "Options:")
145
self.assertContainsRe(help_x, "Description:")
146
self.assertContainsRe(help_x, "Examples:")
147
self.assertContainsRe(help_x, "See also:")
148
self.assertContainsRe(help_x, "Aliases:")
150
def test_help_usage(self):
151
usage = self.run_bzr('diff --usage')[0]
152
self.assertContainsRe(usage, "Purpose:")
153
self.assertContainsRe(usage, "Usage:")
154
self.assertContainsRe(usage, "Options:")
155
self.assertNotContainsRe(usage, "Description:")
156
self.assertNotContainsRe(usage, "Examples:")
157
self.assertContainsRe(usage, "See also:")
158
self.assertContainsRe(usage, "Aliases:")
99
160
def test_help_help(self):
100
help = self.runbzr('help help')[0]
101
qmark = self.runbzr('? ?')[0]
161
help = self.run_bzr('help help')[0]
162
qmark = self.run_bzr('? ?')[0]
102
163
self.assertEquals(help, qmark)
103
164
for line in help.split('\n'):
104
165
if '--long' in line:
105
self.assertTrue('show help on all commands' in line)
166
self.assertContainsRe(line,
167
r'Show help on all commands\.')
169
def test_help_with_aliases(self):
170
original = self.run_bzr('help cat')[0]
172
conf = config.GlobalConfig.from_string('''[ALIASES]
177
expected = original + "'bzr cat' is an alias for 'bzr cat'.\n"
178
self.assertEqual(expected, self.run_bzr('help cat')[0])
180
self.assertEqual("'bzr c' is an alias for 'bzr cat'.\n",
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:")