/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/blackbox/test_help.py

  • Committer: Marius Kruger
  • Date: 2010-07-10 21:28:56 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100710212856-uq4ji3go0u5se7hx
* Update documentation
* add NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009, 2010 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
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
"""Black-box tests for brz help.
 
18
"""Black-box tests for bzr help.
19
19
"""
20
20
 
21
21
 
22
 
from breezy import (
23
 
    config,
24
 
    i18n,
25
 
    tests,
26
 
    )
27
 
 
28
 
from breezy.tests.test_i18n import ZzzTranslations
29
 
 
30
 
 
31
 
class TestHelp(tests.TestCaseWithTransport):
 
22
import bzrlib
 
23
from bzrlib.tests import TestCaseWithTransport
 
24
from bzrlib.config import (ensure_config_dir_exists, config_filename)
 
25
 
 
26
 
 
27
class TestHelp(TestCaseWithTransport):
32
28
 
33
29
    def test_help_basic(self):
34
30
        for cmd in ['--help', 'help', '-h', '-?']:
35
31
            output = self.run_bzr(cmd)[0]
36
32
            line1 = output.split('\n')[0]
37
 
            if not line1.startswith('Breezy'):
38
 
                self.fail("bad output from brz %s:\n%r" % (cmd, output))
 
33
            if not line1.startswith('Bazaar'):
 
34
                self.fail("bad output from bzr %s:\n%r" % (cmd, output))
39
35
        # see https://launchpad.net/products/bzr/+bug/35940, -h doesn't work
40
36
 
41
37
    def test_help_topics(self):
42
 
        """Smoketest for 'brz help topics'"""
 
38
        """Smoketest for 'bzr help topics'"""
43
39
        out, err = self.run_bzr('help topics')
44
40
        self.assertContainsRe(out, 'basic')
45
41
        self.assertContainsRe(out, 'topics')
47
43
        self.assertContainsRe(out, 'revisionspec')
48
44
 
49
45
    def test_help_revisionspec(self):
50
 
        """Smoke test for 'brz help revisionspec'"""
 
46
        """Smoke test for 'bzr help revisionspec'"""
51
47
        out, err = self.run_bzr('help revisionspec')
52
48
        self.assertContainsRe(out, 'revno:')
53
49
        self.assertContainsRe(out, 'date:')
58
54
        self.assertContainsRe(out, 'branch:')
59
55
 
60
56
    def test_help_checkouts(self):
61
 
        """Smoke test for 'brz help checkouts'"""
 
57
        """Smoke test for 'bzr help checkouts'"""
62
58
        out, err = self.run_bzr('help checkouts')
63
59
        self.assertContainsRe(out, 'checkout')
64
60
        self.assertContainsRe(out, 'lightweight')
65
61
 
66
62
    def test_help_urlspec(self):
67
 
        """Smoke test for 'brz help urlspec'"""
 
63
        """Smoke test for 'bzr help urlspec'"""
68
64
        out, err = self.run_bzr('help urlspec')
 
65
        self.assertContainsRe(out, 'aftp://')
69
66
        self.assertContainsRe(out, 'bzr://')
70
 
        self.assertContainsRe(out, 'bzr\\+ssh://')
 
67
        self.assertContainsRe(out, 'bzr\+ssh://')
71
68
        self.assertContainsRe(out, 'file://')
 
69
        self.assertContainsRe(out, 'ftp://')
72
70
        self.assertContainsRe(out, 'http://')
73
71
        self.assertContainsRe(out, 'https://')
74
72
        self.assertContainsRe(out, 'sftp://')
75
73
 
76
74
    def test_help_repositories(self):
77
 
        """Smoke test for 'brz help repositories'"""
 
75
        """Smoke test for 'bzr help repositories'"""
78
76
        out, err = self.run_bzr('help repositories')
79
 
        from breezy.help_topics import help_as_plain_text, _repositories
 
77
        from bzrlib.help_topics import help_as_plain_text, _repositories
80
78
        expected = help_as_plain_text(_repositories)
81
79
        self.assertEqual(expected, out)
82
80
 
83
81
    def test_help_working_trees(self):
84
 
        """Smoke test for 'brz help working-trees'"""
 
82
        """Smoke test for 'bzr help working-trees'"""
85
83
        out, err = self.run_bzr('help working-trees')
86
 
        from breezy.help_topics import help_as_plain_text, _working_trees
 
84
        from bzrlib.help_topics import help_as_plain_text, _working_trees
87
85
        expected = help_as_plain_text(_working_trees)
88
86
        self.assertEqual(expected, out)
89
87
 
90
88
    def test_help_status_flags(self):
91
 
        """Smoke test for 'brz help status-flags'"""
 
89
        """Smoke test for 'bzr help status-flags'"""
92
90
        out, err = self.run_bzr('help status-flags')
93
 
        from breezy.help_topics import help_as_plain_text, _status_flags
 
91
        from bzrlib.help_topics import help_as_plain_text, _status_flags
94
92
        expected = help_as_plain_text(_status_flags)
95
93
        self.assertEqual(expected, out)
96
94
 
97
95
    def test_help_commands(self):
98
 
        dash_help = self.run_bzr('--help commands')[0]
99
 
        commands = self.run_bzr('help commands')[0]
 
96
        dash_help  = self.run_bzr('--help commands')[0]
 
97
        commands   = self.run_bzr('help commands')[0]
100
98
        hidden = self.run_bzr('help hidden-commands')[0]
101
 
        long_help = self.run_bzr('help --long')[0]
 
99
        long_help  = self.run_bzr('help --long')[0]
102
100
        qmark_long = self.run_bzr('? --long')[0]
103
101
        qmark_cmds = self.run_bzr('? commands')[0]
104
 
        self.assertEqual(dash_help, commands)
105
 
        self.assertEqual(dash_help, long_help)
106
 
        self.assertEqual(dash_help, qmark_long)
107
 
        self.assertEqual(dash_help, qmark_cmds)
108
 
 
109
 
    def test_help_width_zero(self):
110
 
        self.overrideEnv('BRZ_COLUMNS', '0')
111
 
        self.run_bzr('help commands')
 
102
        self.assertEquals(dash_help, commands)
 
103
        self.assertEquals(dash_help, long_help)
 
104
        self.assertEquals(dash_help, qmark_long)
 
105
        self.assertEquals(dash_help, qmark_cmds)
112
106
 
113
107
    def test_hidden(self):
114
108
        help_commands = self.run_bzr('help commands')[0]
121
115
            cmds = []
122
116
            for line in help_output.split('\n'):
123
117
                if line.startswith(' '):
124
 
                    continue  # help on more than one line
 
118
                    continue # help on more than one line
125
119
                cmd = line.split(' ')[0]
126
120
                if line:
127
121
                    cmds.append(cmd)
134
128
        self.assertTrue('rocks' not in commands)
135
129
 
136
130
    def test_help_detail(self):
137
 
        dash_h = self.run_bzr('diff -h')[0]
138
 
        help_x = self.run_bzr('help diff')[0]
139
 
        self.assertEqual(dash_h, help_x)
 
131
        dash_h  = self.run_bzr('diff -h')[0]
 
132
        help_x  = self.run_bzr('help diff')[0]
 
133
        self.assertEquals(dash_h, help_x)
140
134
        self.assertContainsRe(help_x, "Purpose:")
141
135
        self.assertContainsRe(help_x, "Usage:")
142
136
        self.assertContainsRe(help_x, "Options:")
146
140
        self.assertContainsRe(help_x, "Aliases:")
147
141
 
148
142
    def test_help_usage(self):
149
 
        usage = self.run_bzr('diff --usage')[0]
 
143
        usage  = self.run_bzr('diff --usage')[0]
150
144
        self.assertContainsRe(usage, "Purpose:")
151
145
        self.assertContainsRe(usage, "Usage:")
152
146
        self.assertContainsRe(usage, "Options:")
158
152
    def test_help_help(self):
159
153
        help = self.run_bzr('help help')[0]
160
154
        qmark = self.run_bzr('? ?')[0]
161
 
        self.assertEqual(help, qmark)
 
155
        self.assertEquals(help, qmark)
162
156
        for line in help.split('\n'):
163
157
            if '--long' in line:
164
158
                self.assertContainsRe(line,
165
 
                                      r'Show help on all commands\.')
 
159
                    r'Show help on all commands\.')
166
160
 
167
161
    def test_help_with_aliases(self):
168
162
        original = self.run_bzr('help cat')[0]
169
163
 
170
 
        conf = config.GlobalConfig.from_string('''[ALIASES]
171
 
c=cat
172
 
cat=cat
173
 
''', save=True)
174
 
 
175
 
        expected = original + "'brz cat' is an alias for 'brz cat'.\n"
 
164
        ensure_config_dir_exists()
 
165
        CONFIG=("[ALIASES]\n"
 
166
        "c=cat\n"
 
167
        "cat=cat\n")
 
168
 
 
169
        open(config_filename(),'wb').write(CONFIG)
 
170
 
 
171
        expected = original + "'bzr cat' is an alias for 'bzr cat'.\n"
176
172
        self.assertEqual(expected, self.run_bzr('help cat')[0])
177
173
 
178
 
        self.assertEqual("'brz c' is an alias for 'brz cat'.\n",
 
174
        self.assertEqual("'bzr c' is an alias for 'bzr cat'.\n",
179
175
                         self.run_bzr('help c')[0])
180
 
 
181
 
 
182
 
class TestTranslatedHelp(tests.TestCaseWithTransport):
183
 
    """Tests for display of translated help topics"""
184
 
 
185
 
    def setUp(self):
186
 
        super(TestTranslatedHelp, self).setUp()
187
 
        self.overrideAttr(i18n, '_translations', ZzzTranslations())
188
 
 
189
 
    def test_help_command_utf8(self):
190
 
        out, err = self.run_bzr_raw(["help", "push"], encoding="utf-8")
191
 
        self.assertContainsRe(out, b"zz\xc3\xa5{{:See also:")
192
 
 
193
 
    def test_help_switch_utf8(self):
194
 
        out, err = self.run_bzr_raw(["push", "--help"], encoding="utf-8")
195
 
        self.assertContainsRe(out, b"zz\xc3\xa5{{:See also:")
196
 
 
197
 
    def test_help_command_ascii(self):
198
 
        out, err = self.run_bzr_raw(["help", "push"], encoding="ascii")
199
 
        self.assertContainsRe(out, b"zz\\?{{:See also:")
200
 
 
201
 
    def test_help_switch_ascii(self):
202
 
        out, err = self.run_bzr_raw(["push", "--help"], encoding="ascii")
203
 
        self.assertContainsRe(out, b"zz\\?{{:See also:")