243
244
self.assertEqual('it sure does!\n', out)
244
245
self.assertEqual('', err)
247
def test_start_and_stop_bzr_subprocess(self):
248
"""We can start and perform other test actions while that process is
251
process = self.start_bzr_subprocess(['--version'])
252
result = self.finish_bzr_subprocess(process)
253
self.assertContainsRe(result[0], 'is free software')
254
self.assertEqual('', result[1])
256
def test_start_and_stop_bzr_subprocess_with_error(self):
257
"""finish_bzr_subprocess allows specification of the desired exit code.
259
process = self.start_bzr_subprocess(['--versionn'])
260
result = self.finish_bzr_subprocess(process, retcode=3)
261
self.assertEqual('', result[0])
262
self.assertContainsRe(result[1], 'unknown command')
264
def test_start_and_stop_bzr_subprocess_ignoring_retcode(self):
265
"""finish_bzr_subprocess allows the exit code to be ignored."""
266
process = self.start_bzr_subprocess(['--versionn'])
267
result = self.finish_bzr_subprocess(process, retcode=None)
268
self.assertEqual('', result[0])
269
self.assertContainsRe(result[1], 'unknown command')
271
def test_start_and_stop_bzr_subprocess_with_unexpected_retcode(self):
272
"""finish_bzr_subprocess raises self.failureException if the retcode is
273
not the expected one.
275
process = self.start_bzr_subprocess(['--versionn'])
276
self.assertRaises(self.failureException, self.finish_bzr_subprocess,
279
def test_start_and_stop_bzr_subprocess_send_signal(self):
280
"""finish_bzr_subprocess raises self.failureException if the retcode is
281
not the expected one.
283
process = self.start_bzr_subprocess(['wait-until-signalled'],
284
skip_if_plan_to_signal=True)
285
self.assertEqual('running\n', process.stdout.readline())
286
result = self.finish_bzr_subprocess(process, send_signal=signal.SIGINT,
288
self.assertEqual('', result[0])
289
self.assertEqual('bzr: interrupted\n', result[1])
247
292
class TestRunBzrError(ExternalBase):