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

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 01:35:53 UTC
  • mto: (6670.4.8 move-bzr)
  • mto: This revision was merged to the branch mainline in revision 6681.
  • Revision ID: jelmer@jelmer.uk-20170610013553-560y7mn3su4pp763
Fix remaining tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009-2012, 2016 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 bzr help.
 
18
"""Black-box tests for brz help.
19
19
"""
20
20
 
21
21
 
22
 
import bzrlib
23
 
from bzrlib.tests.blackbox import ExternalBase
24
 
from bzrlib.config import (ensure_config_dir_exists, config_filename)
25
 
 
26
 
 
27
 
class TestHelp(ExternalBase):
 
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):
28
32
 
29
33
    def test_help_basic(self):
30
34
        for cmd in ['--help', 'help', '-h', '-?']:
31
35
            output = self.run_bzr(cmd)[0]
32
36
            line1 = output.split('\n')[0]
33
 
            if not line1.startswith('Bazaar'):
34
 
                self.fail("bad output from bzr %s:\n%r" % (cmd, output))
 
37
            if not line1.startswith('Breezy'):
 
38
                self.fail("bad output from brz %s:\n%r" % (cmd, output))
35
39
        # see https://launchpad.net/products/bzr/+bug/35940, -h doesn't work
36
40
 
37
41
    def test_help_topics(self):
38
 
        """Smoketest for 'bzr help topics'"""
 
42
        """Smoketest for 'brz help topics'"""
39
43
        out, err = self.run_bzr('help topics')
40
44
        self.assertContainsRe(out, 'basic')
41
45
        self.assertContainsRe(out, 'topics')
43
47
        self.assertContainsRe(out, 'revisionspec')
44
48
 
45
49
    def test_help_revisionspec(self):
46
 
        """Smoke test for 'bzr help revisionspec'"""
 
50
        """Smoke test for 'brz help revisionspec'"""
47
51
        out, err = self.run_bzr('help revisionspec')
48
52
        self.assertContainsRe(out, 'revno:')
49
53
        self.assertContainsRe(out, 'date:')
54
58
        self.assertContainsRe(out, 'branch:')
55
59
 
56
60
    def test_help_checkouts(self):
57
 
        """Smoke test for 'bzr help checkouts'"""
 
61
        """Smoke test for 'brz help checkouts'"""
58
62
        out, err = self.run_bzr('help checkouts')
59
63
        self.assertContainsRe(out, 'checkout')
60
64
        self.assertContainsRe(out, 'lightweight')
61
65
 
62
66
    def test_help_urlspec(self):
63
 
        """Smoke test for 'bzr help urlspec'"""
 
67
        """Smoke test for 'brz help urlspec'"""
64
68
        out, err = self.run_bzr('help urlspec')
65
69
        self.assertContainsRe(out, 'aftp://')
66
70
        self.assertContainsRe(out, 'bzr://')
72
76
        self.assertContainsRe(out, 'sftp://')
73
77
 
74
78
    def test_help_repositories(self):
75
 
        """Smoke test for 'bzr help repositories'"""
 
79
        """Smoke test for 'brz help repositories'"""
76
80
        out, err = self.run_bzr('help repositories')
77
 
        from bzrlib.help_topics import help_as_plain_text, _repositories
 
81
        from breezy.help_topics import help_as_plain_text, _repositories
78
82
        expected = help_as_plain_text(_repositories)
79
83
        self.assertEqual(expected, out)
80
84
 
81
85
    def test_help_working_trees(self):
82
 
        """Smoke test for 'bzr help working-trees'"""
 
86
        """Smoke test for 'brz help working-trees'"""
83
87
        out, err = self.run_bzr('help working-trees')
84
 
        from bzrlib.help_topics import help_as_plain_text, _working_trees
 
88
        from breezy.help_topics import help_as_plain_text, _working_trees
85
89
        expected = help_as_plain_text(_working_trees)
86
90
        self.assertEqual(expected, out)
87
91
 
88
92
    def test_help_status_flags(self):
89
 
        """Smoke test for 'bzr help status-flags'"""
 
93
        """Smoke test for 'brz help status-flags'"""
90
94
        out, err = self.run_bzr('help status-flags')
91
 
        from bzrlib.help_topics import help_as_plain_text, _status_flags
 
95
        from breezy.help_topics import help_as_plain_text, _status_flags
92
96
        expected = help_as_plain_text(_status_flags)
93
97
        self.assertEqual(expected, out)
94
98
 
99
103
        long_help  = self.run_bzr('help --long')[0]
100
104
        qmark_long = self.run_bzr('? --long')[0]
101
105
        qmark_cmds = self.run_bzr('? commands')[0]
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)
 
106
        self.assertEqual(dash_help, commands)
 
107
        self.assertEqual(dash_help, long_help)
 
108
        self.assertEqual(dash_help, qmark_long)
 
109
        self.assertEqual(dash_help, qmark_cmds)
 
110
 
 
111
    def test_help_width_zero(self):
 
112
        self.overrideEnv('BRZ_COLUMNS', '0')
 
113
        self.run_bzr('help commands')
106
114
 
107
115
    def test_hidden(self):
108
116
        help_commands = self.run_bzr('help commands')[0]
130
138
    def test_help_detail(self):
131
139
        dash_h  = self.run_bzr('diff -h')[0]
132
140
        help_x  = self.run_bzr('help diff')[0]
133
 
        self.assertEquals(dash_h, help_x)
 
141
        self.assertEqual(dash_h, help_x)
134
142
        self.assertContainsRe(help_x, "Purpose:")
135
143
        self.assertContainsRe(help_x, "Usage:")
136
144
        self.assertContainsRe(help_x, "Options:")
152
160
    def test_help_help(self):
153
161
        help = self.run_bzr('help help')[0]
154
162
        qmark = self.run_bzr('? ?')[0]
155
 
        self.assertEquals(help, qmark)
 
163
        self.assertEqual(help, qmark)
156
164
        for line in help.split('\n'):
157
165
            if '--long' in line:
158
166
                self.assertContainsRe(line,
161
169
    def test_help_with_aliases(self):
162
170
        original = self.run_bzr('help cat')[0]
163
171
 
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"
 
172
        conf = config.GlobalConfig.from_string('''[ALIASES]
 
173
c=cat
 
174
cat=cat
 
175
''', save=True)
 
176
 
 
177
        expected = original + "'brz cat' is an alias for 'brz cat'.\n"
172
178
        self.assertEqual(expected, self.run_bzr('help cat')[0])
173
179
 
174
 
        self.assertEqual("'bzr c' is an alias for 'bzr cat'.\n",
 
180
        self.assertEqual("'brz c' is an alias for 'brz cat'.\n",
175
181
                         self.run_bzr('help c')[0])
 
182
 
 
183
 
 
184
class TestTranslatedHelp(tests.TestCaseWithTransport):
 
185
    """Tests for display of translated help topics"""
 
186
 
 
187
    def setUp(self):
 
188
        super(TestTranslatedHelp, self).setUp()
 
189
        self.overrideAttr(i18n, '_translations', ZzzTranslations())
 
190
 
 
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:")
 
194
 
 
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:")
 
198
 
 
199
    def test_help_command_ascii(self):
 
200
        out, err = self.run_bzr(["help", "push"], encoding="ascii")
 
201
        self.assertContainsRe(out, "zz\\?{{:See also:")
 
202
 
 
203
    def test_help_switch_ascii(self):
 
204
        out, err = self.run_bzr(["push", "--help"], encoding="ascii")
 
205
        self.assertContainsRe(out, "zz\\?{{:See also:")