bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
1 |
# Copyright (C) 2010 by Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
5636.1.2
by Vincent Ladeuil
Raise KnownFailure on windows for bug #709104. |
17 |
import sys |
18 |
||
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
19 |
import breezy |
7027.6.1
by Jelmer Vernooij
Fix bash completion tests on Python 3. |
20 |
from breezy import commands, osutils, tests |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
21 |
from breezy.tests import features |
22 |
from breezy.plugins.bash_completion.bashcomp import * |
|
5147.5.13
by Martin von Gagern
Import modules in tests, not classes or functions. |
23 |
|
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
24 |
import subprocess |
5147.5.13
by Martin von Gagern
Import modules in tests, not classes or functions. |
25 |
|
26 |
||
0.32.5
by Martin von Gagern
Test bash completion for tags. |
27 |
class BashCompletionMixin(object): |
28 |
"""Component for testing execution of a bash completion script.""" |
|
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
29 |
|
5255.4.4
by Martin von Gagern
Properly import bzrlib.tests.features. |
30 |
_test_needs_features = [features.bash_feature] |
5636.1.1
by Vincent Ladeuil
Get rid of the useless __init__. |
31 |
script = None |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
32 |
|
0.32.11
by Martin von Gagern
Turn completion assertions into separate methods. |
33 |
def complete(self, words, cword=-1): |
0.32.5
by Martin von Gagern
Test bash completion for tags. |
34 |
"""Perform a bash completion. |
35 |
||
36 |
:param words: a list of words representing the current command.
|
|
37 |
:param cword: the current word to complete, defaults to the last one.
|
|
38 |
"""
|
|
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
39 |
if self.script is None: |
40 |
self.script = self.get_script() |
|
5255.4.4
by Martin von Gagern
Properly import bzrlib.tests.features. |
41 |
proc = subprocess.Popen([features.bash_feature.path, |
5147.5.24
by Martin von Gagern
Move ExecutableFeature instances to tests.features module. |
42 |
'--noprofile'], |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
43 |
stdin=subprocess.PIPE, |
44 |
stdout=subprocess.PIPE, |
|
45 |
stderr=subprocess.PIPE) |
|
46 |
if cword < 0: |
|
47 |
cword = len(words) + cword |
|
7027.6.1
by Jelmer Vernooij
Fix bash completion tests on Python 3. |
48 |
encoding = osutils.get_user_encoding() |
49 |
input = b'%s\n' % self.script.encode(encoding) |
|
50 |
input += (b'COMP_WORDS=( %s )\n' % |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
51 |
b' '.join([b"'" + w.replace("'", "'\\''").encode(encoding) + b"'" for w in words])) |
7027.6.1
by Jelmer Vernooij
Fix bash completion tests on Python 3. |
52 |
input += b'COMP_CWORD=%d\n' % cword |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
53 |
input += b'%s\n' % getattr(self, 'script_name', |
54 |
'_brz').encode(encoding) |
|
7027.6.1
by Jelmer Vernooij
Fix bash completion tests on Python 3. |
55 |
input += b'echo ${#COMPREPLY[*]}\n' |
56 |
input += b"IFS=$'\\n'\n" |
|
57 |
input += b'echo "${COMPREPLY[*]}"\n' |
|
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
58 |
(out, err) = proc.communicate(input) |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
59 |
if b'' != err: |
0.32.5
by Martin von Gagern
Test bash completion for tags. |
60 |
raise AssertionError('Unexpected error message:\n%s' % err) |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
61 |
self.assertEqual(b'', err, 'No messages to standard error') |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
62 |
#import sys
|
63 |
#print >>sys.stdout, '---\n%s\n---\n%s\n---\n' % (input, out)
|
|
7027.6.1
by Jelmer Vernooij
Fix bash completion tests on Python 3. |
64 |
lines = out.split(b'\n') |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
65 |
nlines = int(lines[0]) |
66 |
del lines[0] |
|
7027.6.1
by Jelmer Vernooij
Fix bash completion tests on Python 3. |
67 |
self.assertEqual(b'', lines[-1], 'Newline at end') |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
68 |
del lines[-1] |
7027.6.1
by Jelmer Vernooij
Fix bash completion tests on Python 3. |
69 |
if nlines == 0 and len(lines) == 1 and lines[0] == b'': |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
70 |
del lines[0] |
71 |
self.assertEqual(nlines, len(lines), 'No newlines in generated words') |
|
7027.6.1
by Jelmer Vernooij
Fix bash completion tests on Python 3. |
72 |
self.completion_result = {l.decode(encoding) for l in lines} |
0.32.11
by Martin von Gagern
Turn completion assertions into separate methods. |
73 |
return self.completion_result |
74 |
||
75 |
def assertCompletionEquals(self, *words): |
|
76 |
self.assertEqual(set(words), self.completion_result) |
|
77 |
||
78 |
def assertCompletionContains(self, *words): |
|
79 |
missing = set(words) - self.completion_result |
|
0.32.5
by Martin von Gagern
Test bash completion for tags. |
80 |
if missing: |
81 |
raise AssertionError('Completion should contain %r but it has %r' |
|
0.32.11
by Martin von Gagern
Turn completion assertions into separate methods. |
82 |
% (missing, self.completion_result)) |
83 |
||
84 |
def assertCompletionOmits(self, *words): |
|
85 |
surplus = set(words) & self.completion_result |
|
0.32.5
by Martin von Gagern
Test bash completion for tags. |
86 |
if surplus: |
87 |
raise AssertionError('Completion should omit %r but it has %r' |
|
7290.49.1
by Jelmer Vernooij
Fix flake errors. |
88 |
% (surplus, self.completion_result)) |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
89 |
|
90 |
def get_script(self): |
|
0.32.12
by Martin von Gagern
Duplicate script creation steps in get_script testing method. |
91 |
commands.install_bzr_command_hooks() |
92 |
dc = DataCollector() |
|
93 |
data = dc.collect() |
|
94 |
cg = BashCodeGen(data) |
|
95 |
res = cg.function() |
|
96 |
return res |
|
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
97 |
|
0.32.5
by Martin von Gagern
Test bash completion for tags. |
98 |
|
5147.5.13
by Martin von Gagern
Import modules in tests, not classes or functions. |
99 |
class TestBashCompletion(tests.TestCase, BashCompletionMixin): |
6622.1.31
by Jelmer Vernooij
Fix more tests. |
100 |
"""Test bash completions that don't execute brz.""" |
0.32.5
by Martin von Gagern
Test bash completion for tags. |
101 |
|
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
102 |
def test_simple_scipt(self): |
103 |
"""Ensure that the test harness works as expected""" |
|
104 |
self.script = """ |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
105 |
_brz() {
|
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
106 |
COMPREPLY=()
|
107 |
# add all words in reverse order, with some markup around them
|
|
108 |
for ((i = ${#COMP_WORDS[@]}; i > 0; --i)); do
|
|
109 |
COMPREPLY+=( "-${COMP_WORDS[i-1]}+" ) |
|
110 |
done
|
|
111 |
# and append the current word
|
|
112 |
COMPREPLY+=( "+${COMP_WORDS[COMP_CWORD]}-" ) |
|
113 |
}
|
|
114 |
"""
|
|
0.32.11
by Martin von Gagern
Turn completion assertions into separate methods. |
115 |
self.complete(['foo', '"bar', "'baz"], cword=1) |
116 |
self.assertCompletionEquals("-'baz+", '-"bar+', '-foo+', '+"bar-') |
|
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
117 |
|
118 |
def test_cmd_ini(self): |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
119 |
self.complete(['brz', 'ini']) |
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
120 |
self.assertCompletionContains( |
121 |
'init', 'init-shared-repo', 'init-shared-repository') |
|
0.32.11
by Martin von Gagern
Turn completion assertions into separate methods. |
122 |
self.assertCompletionOmits('commit') |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
123 |
|
124 |
def test_init_opts(self): |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
125 |
self.complete(['brz', 'init', '-']) |
6708.1.3
by Neil Martinsen-Burrell
Fix tests that used format names |
126 |
self.assertCompletionContains('-h', '--format=2a') |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
127 |
|
128 |
def test_global_opts(self): |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
129 |
self.complete(['brz', '-', 'init'], cword=1) |
0.32.11
by Martin von Gagern
Turn completion assertions into separate methods. |
130 |
self.assertCompletionContains('--no-plugins', '--builtin') |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
131 |
|
132 |
def test_commit_dashm(self): |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
133 |
self.complete(['brz', 'commit', '-m']) |
0.32.11
by Martin von Gagern
Turn completion assertions into separate methods. |
134 |
self.assertCompletionEquals('-m') |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
135 |
|
136 |
def test_status_negated(self): |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
137 |
self.complete(['brz', 'status', '--n']) |
0.32.11
by Martin von Gagern
Turn completion assertions into separate methods. |
138 |
self.assertCompletionContains('--no-versioned', '--no-verbose') |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
139 |
|
140 |
def test_init_format_any(self): |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
141 |
self.complete(['brz', 'init', '--format', '=', 'directory'], cword=3) |
0.32.11
by Martin von Gagern
Turn completion assertions into separate methods. |
142 |
self.assertCompletionContains('1.9', '2a') |
0.32.4
by Martin von Gagern
Added some selftests executed through bash. |
143 |
|
144 |
def test_init_format_2(self): |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
145 |
self.complete(['brz', 'init', '--format', '=', '2', 'directory'], |
0.32.11
by Martin von Gagern
Turn completion assertions into separate methods. |
146 |
cword=4) |
147 |
self.assertCompletionContains('2a') |
|
148 |
self.assertCompletionOmits('1.9') |
|
0.32.5
by Martin von Gagern
Test bash completion for tags. |
149 |
|
150 |
||
5147.5.13
by Martin von Gagern
Import modules in tests, not classes or functions. |
151 |
class TestBashCompletionInvoking(tests.TestCaseWithTransport, |
152 |
BashCompletionMixin): |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
153 |
"""Test bash completions that might execute brz. |
0.32.5
by Martin von Gagern
Test bash completion for tags. |
154 |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
155 |
Only the syntax ``$(brz ...`` is supported so far. The brz command
|
156 |
will be replaced by the brz instance running this selftest.
|
|
0.32.5
by Martin von Gagern
Test bash completion for tags. |
157 |
"""
|
158 |
||
5636.1.2
by Vincent Ladeuil
Raise KnownFailure on windows for bug #709104. |
159 |
def setUp(self): |
160 |
super(TestBashCompletionInvoking, self).setUp() |
|
161 |
if sys.platform == 'win32': |
|
162 |
raise tests.KnownFailure( |
|
163 |
'see bug #709104, completion is broken on windows') |
|
0.32.5
by Martin von Gagern
Test bash completion for tags. |
164 |
|
165 |
def get_script(self): |
|
166 |
s = super(TestBashCompletionInvoking, self).get_script() |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
167 |
return s.replace("$(brz ", "$('%s' " % self.get_brz_path()) |
0.32.5
by Martin von Gagern
Test bash completion for tags. |
168 |
|
169 |
def test_revspec_tag_all(self): |
|
5255.4.4
by Martin von Gagern
Properly import bzrlib.tests.features. |
170 |
self.requireFeature(features.sed_feature) |
0.32.7
by Martin von Gagern
Allow different formats for tag completion. |
171 |
wt = self.make_branch_and_tree('.', format='dirstate-tags') |
6973.14.6
by Jelmer Vernooij
Fix some more tests. |
172 |
wt.branch.tags.set_tag('tag1', b'null:') |
173 |
wt.branch.tags.set_tag('tag2', b'null:') |
|
174 |
wt.branch.tags.set_tag('3tag', b'null:') |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
175 |
self.complete(['brz', 'log', '-r', 'tag', ':']) |
0.32.16
by Martin von Gagern
Ensure proper quoting of spaces in tag names. |
176 |
self.assertCompletionEquals('tag1', 'tag2', '3tag') |
0.32.5
by Martin von Gagern
Test bash completion for tags. |
177 |
|
178 |
def test_revspec_tag_prefix(self): |
|
5255.4.4
by Martin von Gagern
Properly import bzrlib.tests.features. |
179 |
self.requireFeature(features.sed_feature) |
0.32.7
by Martin von Gagern
Allow different formats for tag completion. |
180 |
wt = self.make_branch_and_tree('.', format='dirstate-tags') |
6973.14.6
by Jelmer Vernooij
Fix some more tests. |
181 |
wt.branch.tags.set_tag('tag1', b'null:') |
182 |
wt.branch.tags.set_tag('tag2', b'null:') |
|
183 |
wt.branch.tags.set_tag('3tag', b'null:') |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
184 |
self.complete(['brz', 'log', '-r', 'tag', ':', 't']) |
0.32.16
by Martin von Gagern
Ensure proper quoting of spaces in tag names. |
185 |
self.assertCompletionEquals('tag1', 'tag2') |
186 |
||
187 |
def test_revspec_tag_spaces(self): |
|
5255.4.4
by Martin von Gagern
Properly import bzrlib.tests.features. |
188 |
self.requireFeature(features.sed_feature) |
0.32.16
by Martin von Gagern
Ensure proper quoting of spaces in tag names. |
189 |
wt = self.make_branch_and_tree('.', format='dirstate-tags') |
6973.14.6
by Jelmer Vernooij
Fix some more tests. |
190 |
wt.branch.tags.set_tag('tag with spaces', b'null:') |
6622.1.31
by Jelmer Vernooij
Fix more tests. |
191 |
self.complete(['brz', 'log', '-r', 'tag', ':', 't']) |
0.32.16
by Martin von Gagern
Ensure proper quoting of spaces in tag names. |
192 |
self.assertCompletionEquals(r'tag\ with\ spaces') |
6622.1.31
by Jelmer Vernooij
Fix more tests. |
193 |
self.complete(['brz', 'log', '-r', '"tag:t']) |
0.32.16
by Martin von Gagern
Ensure proper quoting of spaces in tag names. |
194 |
self.assertCompletionEquals('tag:tag with spaces') |
6622.1.31
by Jelmer Vernooij
Fix more tests. |
195 |
self.complete(['brz', 'log', '-r', "'tag:t"]) |
0.32.16
by Martin von Gagern
Ensure proper quoting of spaces in tag names. |
196 |
self.assertCompletionEquals('tag:tag with spaces') |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
197 |
|
0.32.20
by Martin von Gagern
Allow completion of tags at end of revision range. |
198 |
def test_revspec_tag_endrange(self): |
5255.4.4
by Martin von Gagern
Properly import bzrlib.tests.features. |
199 |
self.requireFeature(features.sed_feature) |
0.32.20
by Martin von Gagern
Allow completion of tags at end of revision range. |
200 |
wt = self.make_branch_and_tree('.', format='dirstate-tags') |
6973.14.6
by Jelmer Vernooij
Fix some more tests. |
201 |
wt.branch.tags.set_tag('tag1', b'null:') |
202 |
wt.branch.tags.set_tag('tag2', b'null:') |
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
203 |
self.complete(['brz', 'log', '-r', '3..tag', ':', 't']) |
0.32.20
by Martin von Gagern
Allow completion of tags at end of revision range. |
204 |
self.assertCompletionEquals('tag1', 'tag2') |
6622.1.31
by Jelmer Vernooij
Fix more tests. |
205 |
self.complete(['brz', 'log', '-r', '"3..tag:t']) |
0.32.20
by Martin von Gagern
Allow completion of tags at end of revision range. |
206 |
self.assertCompletionEquals('3..tag:tag1', '3..tag:tag2') |
6622.1.31
by Jelmer Vernooij
Fix more tests. |
207 |
self.complete(['brz', 'log', '-r', "'3..tag:t"]) |
0.32.20
by Martin von Gagern
Allow completion of tags at end of revision range. |
208 |
self.assertCompletionEquals('3..tag:tag1', '3..tag:tag2') |
209 |
||
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
210 |
|
5147.5.13
by Martin von Gagern
Import modules in tests, not classes or functions. |
211 |
class TestBashCodeGen(tests.TestCase): |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
212 |
|
213 |
def test_command_names(self): |
|
214 |
data = CompletionData() |
|
215 |
bar = CommandData('bar') |
|
216 |
bar.aliases.append('baz') |
|
217 |
data.commands.append(bar) |
|
218 |
data.commands.append(CommandData('foo')) |
|
219 |
cg = BashCodeGen(data) |
|
220 |
self.assertEqual('bar baz foo', cg.command_names()) |
|
221 |
||
222 |
def test_debug_output(self): |
|
223 |
data = CompletionData() |
|
224 |
self.assertEqual('', BashCodeGen(data, debug=False).debug_output()) |
|
225 |
self.assertTrue(BashCodeGen(data, debug=True).debug_output()) |
|
226 |
||
6622.1.31
by Jelmer Vernooij
Fix more tests. |
227 |
def test_brz_version(self): |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
228 |
data = CompletionData() |
229 |
cg = BashCodeGen(data) |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
230 |
self.assertEqual('%s.' % breezy.version_string, cg.brz_version()) |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
231 |
data.plugins['foo'] = PluginData('foo', '1.0') |
232 |
data.plugins['bar'] = PluginData('bar', '2.0') |
|
233 |
cg = BashCodeGen(data) |
|
234 |
self.assertEqual('''\ |
|
235 |
%s and the following plugins: |
|
236 |
# bar 2.0
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
237 |
# foo 1.0''' % breezy.version_string, cg.brz_version()) |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
238 |
|
239 |
def test_global_options(self): |
|
240 |
data = CompletionData() |
|
241 |
data.global_options.add('--foo') |
|
242 |
data.global_options.add('--bar') |
|
243 |
cg = BashCodeGen(data) |
|
244 |
self.assertEqual('--bar --foo', cg.global_options()) |
|
245 |
||
246 |
def test_command_cases(self): |
|
247 |
data = CompletionData() |
|
248 |
bar = CommandData('bar') |
|
249 |
bar.aliases.append('baz') |
|
250 |
bar.options.append(OptionData('--opt')) |
|
251 |
data.commands.append(bar) |
|
252 |
data.commands.append(CommandData('foo')) |
|
253 |
cg = BashCodeGen(data) |
|
254 |
self.assertEqualDiff('''\ |
|
255 |
\tbar|baz) |
|
0.32.15
by Martin von Gagern
Allow spaces in tag names. Use bash arrays more extensively. |
256 |
\t\tcmdOpts=( --opt ) |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
257 |
\t\t;; |
258 |
\tfoo) |
|
0.32.15
by Martin von Gagern
Allow spaces in tag names. Use bash arrays more extensively. |
259 |
\t\tcmdOpts=( ) |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
260 |
\t\t;; |
261 |
''', cg.command_cases()) |
|
262 |
||
263 |
def test_command_case(self): |
|
264 |
cmd = CommandData('cmd') |
|
265 |
cmd.plugin = PluginData('plugger', '1.0') |
|
266 |
bar = OptionData('--bar') |
|
267 |
bar.registry_keys = ['that', 'this'] |
|
268 |
bar.error_messages.append('Some error message') |
|
269 |
cmd.options.append(bar) |
|
270 |
cmd.options.append(OptionData('--foo')) |
|
271 |
data = CompletionData() |
|
272 |
data.commands.append(cmd) |
|
273 |
cg = BashCodeGen(data) |
|
274 |
self.assertEqualDiff('''\ |
|
275 |
\tcmd) |
|
276 |
\t\t# plugin "plugger 1.0" |
|
277 |
\t\t# Some error message |
|
0.32.15
by Martin von Gagern
Allow spaces in tag names. Use bash arrays more extensively. |
278 |
\t\tcmdOpts=( --bar=that --bar=this --foo ) |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
279 |
\t\tcase $curOpt in |
0.32.15
by Martin von Gagern
Allow spaces in tag names. Use bash arrays more extensively. |
280 |
\t\t\t--bar) optEnums=( that this ) ;; |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
281 |
\t\tesac |
282 |
\t\t;; |
|
283 |
''', cg.command_case(cmd)) |
|
284 |
||
285 |
||
5147.5.13
by Martin von Gagern
Import modules in tests, not classes or functions. |
286 |
class TestDataCollector(tests.TestCase): |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
287 |
|
288 |
def setUp(self): |
|
289 |
super(TestDataCollector, self).setUp() |
|
290 |
commands.install_bzr_command_hooks() |
|
291 |
||
292 |
def test_global_options(self): |
|
293 |
dc = DataCollector() |
|
294 |
dc.global_options() |
|
295 |
self.assertSubset(['--no-plugins', '--builtin'], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
296 |
dc.data.global_options) |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
297 |
|
298 |
def test_commands(self): |
|
299 |
dc = DataCollector() |
|
300 |
dc.commands() |
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
301 |
self.assertSubset( |
302 |
['init', 'init-shared-repo', 'init-shared-repository'], |
|
303 |
dc.data.all_command_aliases()) |
|
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
304 |
|
0.32.19
by Martin von Gagern
Add test ensuring plugin commands get collected. |
305 |
def test_commands_from_plugins(self): |
306 |
dc = DataCollector() |
|
307 |
dc.commands() |
|
308 |
self.assertSubset(['bash-completion'], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
309 |
dc.data.all_command_aliases()) |
0.32.19
by Martin von Gagern
Add test ensuring plugin commands get collected. |
310 |
|
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
311 |
def test_commit_dashm(self): |
312 |
dc = DataCollector() |
|
313 |
cmd = dc.command('commit') |
|
314 |
self.assertSubset(['-m'], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
315 |
[str(o) for o in cmd.options]) |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
316 |
|
317 |
def test_status_negated(self): |
|
318 |
dc = DataCollector() |
|
319 |
cmd = dc.command('status') |
|
320 |
self.assertSubset(['--no-versioned', '--no-verbose'], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
321 |
[str(o) for o in cmd.options]) |
0.32.9
by Martin von Gagern
Added test cases for DataCollector and BashCodeGen. |
322 |
|
323 |
def test_init_format(self): |
|
324 |
dc = DataCollector() |
|
325 |
cmd = dc.command('init') |
|
326 |
for opt in cmd.options: |
|
327 |
if opt.name == '--format': |
|
328 |
self.assertSubset(['2a'], opt.registry_keys) |
|
329 |
return
|
|
330 |
raise AssertionError('Option --format not found') |
|
6386.1.1
by Jelmer Vernooij
Fix bash_completion plugin. |
331 |
|
332 |
||
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
333 |
class BlackboxTests(tests.TestCaseWithMemoryTransport): |
6386.1.1
by Jelmer Vernooij
Fix bash_completion plugin. |
334 |
|
335 |
def test_bash_completion(self): |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
336 |
self.run_bzr("bash-completion", encoding="utf-8") |