/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_help.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2007-2011 Canonical Ltd
2
2
#
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
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Unit tests for the breezy.help module."""
 
17
"""Unit tests for the bzrlib.help module."""
18
18
 
19
19
import textwrap
20
20
 
21
 
from .. import (
 
21
from bzrlib import (
22
22
    builtins,
23
23
    commands,
24
24
    config,
30
30
    tests,
31
31
    )
32
32
 
33
 
from .test_i18n import ZzzTranslations
 
33
from bzrlib.tests.test_i18n import ZzzTranslations
34
34
import re
35
35
 
36
36
 
37
 
class TestErrors(tests.TestCase):
38
 
 
39
 
    def test_no_help_topic(self):
40
 
        error = help.NoHelpTopic("topic")
41
 
        self.assertEqualDiff("No help could be found for 'topic'. "
42
 
            "Please use 'brz help topics' to obtain a list of topics.",
43
 
            str(error))
44
 
 
45
 
 
46
37
class TestCommandHelp(tests.TestCase):
47
38
    """Tests for help on commands."""
48
39
 
55
46
            _see_also = ['foo', 'bar']
56
47
        self.assertCmdHelp('''\
57
48
Purpose: A sample command.
58
 
Usage:   brz WithSeeAlso
 
49
Usage:   bzr WithSeeAlso
59
50
 
60
51
Options:
61
52
  --usage        Show usage message and options.
73
64
            __doc__ = """A sample command."""
74
65
        self.assertCmdHelp('''\
75
66
Purpose: A sample command.
76
 
Usage:   brz Demo
 
67
Usage:   bzr Demo
77
68
 
78
69
Options:
79
70
  --usage        Show usage message and options.
87
78
        helptext = cmd.get_help_text()
88
79
        self.assertStartsWith(helptext,
89
80
            'Purpose: A sample command.\n'
90
 
            'Usage:   brz Demo')
 
81
            'Usage:   bzr Demo')
91
82
        self.assertEndsWith(helptext,
92
83
            '  -h, --help     Show help message.\n\n')
93
84
 
143
134
 
144
135
                ::
145
136
 
146
 
                    brz Demo something
 
137
                    bzr Demo something
147
138
            """
148
139
        cmd = cmd_Demo()
149
140
        helptext = cmd.get_help_text()
150
141
        self.assertEqualDiff('''\
151
142
Purpose: A sample command.
152
 
Usage:   brz Demo
 
143
Usage:   bzr Demo
153
144
 
154
145
Options:
155
146
  --usage        Show usage message and options.
168
159
 
169
160
    A code block follows.
170
161
 
171
 
        brz Demo something
 
162
        bzr Demo something
172
163
 
173
164
''',
174
165
                                         helptext)
175
166
        helptext = cmd.get_help_text(plain=False)
176
167
        self.assertEqualDiff('''\
177
168
:Purpose: A sample command.
178
 
:Usage:   brz Demo
 
169
:Usage:   bzr Demo
179
170
 
180
171
:Options:
181
172
  --usage        Show usage message and options.
196
187
 
197
188
    ::
198
189
 
199
 
        brz Demo something
 
190
        bzr Demo something
200
191
 
201
192
''',
202
193
                             helptext)
217
208
        helptext = cmd.get_help_text()
218
209
        self.assertEqualDiff('''\
219
210
Purpose: A sample command.
220
 
Usage:   brz Demo
 
211
Usage:   bzr Demo
221
212
 
222
213
Options:
223
214
  --usage        Show usage message and options.
238
229
        helptext = cmd.get_help_text(verbose=False)
239
230
        self.assertEqualDiff('''\
240
231
Purpose: A sample command.
241
 
Usage:   brz Demo
 
232
Usage:   bzr Demo
242
233
 
243
234
Options:
244
235
  --usage        Show usage message and options.
246
237
  -v, --verbose  Display more information.
247
238
  -h, --help     Show help message.
248
239
 
249
 
See brz help Demo for more details and examples.
 
240
See bzr help Demo for more details and examples.
250
241
 
251
242
''',
252
243
                             helptext)
274
265
        helptext = cmd.get_help_text()
275
266
        self.assertEqualDiff('''\
276
267
Purpose: A sample command.
277
 
Usage:   brz Demo
 
268
Usage:   bzr Demo
278
269
 
279
270
Options:
280
271
  --usage        Show usage message and options.
336
327
 
337
328
class ZzzTranslationsForDoc(ZzzTranslations):
338
329
 
339
 
    _section_pat = re.compile(':\\w+:\\n\\s+')
 
330
    _section_pat = re.compile(':\w+:\\n\\s+')
340
331
    _indent_pat = re.compile('\\s+')
341
332
 
342
333
    def zzz(self, s):
364
355
            _see_also = ['foo', 'bar']
365
356
        self.assertCmdHelp('''\
366
357
zz{{:Purpose: zz{{A sample command.}}
367
 
}}zz{{:Usage:   brz WithSeeAlso
 
358
}}zz{{:Usage:   bzr WithSeeAlso
368
359
}}
369
360
zz{{:Options:
370
361
  --usage        zz{{Show usage message and options.}}
382
373
            __doc__ = """A sample command."""
383
374
        self.assertCmdHelp('''\
384
375
zz{{:Purpose: zz{{A sample command.}}
385
 
}}zz{{:Usage:   brz Demo
 
376
}}zz{{:Usage:   bzr Demo
386
377
}}
387
378
zz{{:Options:
388
379
  --usage        zz{{Show usage message and options.}}
400
391
        cmd = cmd_WithSeeAlso()
401
392
        helptext = cmd.get_help_text(['gam'])
402
393
        self.assertEndsWith(
403
 
            helptext, '''\
 
394
            helptext,'''\
404
395
  -q, --quiet    zz{{Only display errors and warnings.}}
405
396
  -v, --verbose  zz{{Display more information.}}
406
397
  -h, --help     zz{{Show help message.}}
446
437
            """
447
438
        self.assertCmdHelp('''\
448
439
zz{{:Purpose: zz{{A sample command.}}
449
 
}}zz{{:Usage:   brz Demo
 
440
}}zz{{:Usage:   bzr Demo
450
441
}}
451
442
zz{{:Options:
452
443
  --usage        zz{{Show usage message and options.}}
606
597
        self.assertLength(1, topics)
607
598
        opt = topics[0]
608
599
        self.assertIsInstance(opt, config.Option)
609
 
        self.assertEqual('default_format', opt.name)
 
600
        self.assertEquals('default_format', opt.name)
610
601
 
611
602
 
612
603
class TestCommandIndex(TestHelp):
669
660
        """Searching for an unknown topic should raise NoHelpTopic."""
670
661
        indices = help.HelpIndices()
671
662
        indices.search_path = []
672
 
        error = self.assertRaises(help.NoHelpTopic, indices.search, 'foo')
 
663
        error = self.assertRaises(errors.NoHelpTopic, indices.search, 'foo')
673
664
        self.assertEqual('foo', error.topic)
674
665
 
675
666
    def test_search_calls_get_topic(self):