36
36
When no output is specified, any ouput from the command is accepted
37
37
and let the execution continue.
39
40
If an error occurs and no expected error is specified, the execution stops.
41
The matching is done on a full string comparison basis.
42
The matching is done on a full string comparison basis unless '...' is used, in
43
which case expected output/errors can be lees precise.
61
63
2> bzr: ERROR: unknown command "not-a-command"
65
You can use ellipsis (...) to replace any piece of text you don't want to be
68
bzr branch not-a-branch
69
2>bzr: ERROR: Not a branch...not-a-branch/".
65
from cStringIO import StringIO
77
from cStringIO import StringIO
69
79
from bzrlib import (
197
207
def __init__(self, test_case):
198
208
self.test_case = test_case
209
self.output_checker = doctest.OutputChecker()
210
self.check_options = doctest.ELLIPSIS
200
212
def run_script(self, text):
201
213
for cmd, input, output, error in _script_to_commands(text):
202
self.run_command(cmd, input, output, error)
214
out, err = self.run_command(cmd, input, output, error)
204
216
def _check_output(self, expected, actual):
205
217
if expected is None:
206
218
# Specifying None means: any output is accepted
208
self.test_case.assertEquals(expected, actual)
221
self.test_case.fail('Unexpected: %s' % actual)
222
matching = self.output_checker.check_output(
223
expected, actual, self.check_options)
225
# Note that we can't use output_checker.output_difference() here
226
# because... the API is boken (expected must be a doctest specific
227
# object of whicha 'want' attribute will be our 'expected'
228
# parameter. So we just fallbacl to our good old assertEqualDiff
229
# since we know there are differences and the output should be
231
self.test_case.assertEqualDiff(expected, actual)
210
233
def run_command(self, cmd, input, output, error):
211
234
mname = 'do_' + cmd[0]