90
91
"""Return as a string the log for this test"""
91
92
return open(self._log_file_name).read()
95
def run_bzr_captured(self, argv, retcode=0):
96
"""Invoke bzr and return (result, stdout, stderr).
98
Useful for code that wants to check the contents of the
99
output, the way error messages are presented, etc.
101
This should be the main method for tests that want to exercise the
102
overall behavior of the bzr application (rather than a unit test
103
or a functional test of the library.)
105
Much of the old code runs bzr by forking a new copy of Python, but
106
that is slower, harder to debug, and generally not necessary.
108
argv -- arguments to invoke bzr
109
retcode -- expected return code, or None for don't-care.
113
self.log('run bzr: %s', ' '.join(argv))
114
result = self.apply_redirected(None, stdout, stderr,
115
bzrlib.commands.run_bzr, argv)
116
out = stdout.getvalue()
117
err = stderr.getvalue()
119
self.log('output:\n%s', out)
121
self.log('errors:\n%s', err)
122
if retcode is not None:
123
self.assertEquals(result, retcode)
93
127
def run_bzr(self, *args, **kwargs):
94
128
"""Invoke bzr, as if it were run from the command line.
97
131
overall behavior of the bzr application (rather than a unit test
98
132
or a functional test of the library.)
100
Much of the old code runs bzr by forking a new copy of Python, but
101
that is slower, harder to debug, and generally not necessary.
134
This sends the stdout/stderr results into the test's log,
135
where it may be useful for debugging. See also run_captured.
103
retcode = kwargs.get('retcode', 0)
104
result = self.apply_redirected(None, None, None,
105
bzrlib.commands.run_bzr, args)
106
self.assertEquals(result, retcode)
137
warn('TestBase.run_bzr is deprecated, use TestBase.run_bzr_captured')
138
retcode = kwargs.pop('retcode', 0)
139
self.run_bzr_captured(args, retcode)
109
142
def check_inventory_shape(self, inv, shape):
111
144
Compare an inventory to a list of expected names.