64
65
except ParamikoNotPresent:
65
66
raise TestSkipped("Paramiko not present")
66
67
old_transport = bzrlib.tests.default_transport
67
old_root = TestCaseInTempDir.TEST_ROOT
68
TestCaseInTempDir.TEST_ROOT = None
68
old_root = TestCaseWithMemoryTransport.TEST_ROOT
69
TestCaseWithMemoryTransport.TEST_ROOT = None
70
71
TestOptions.current_test = "test_transport_set_to_sftp"
71
72
stdout = self.capture('selftest --transport=sftp test_transport_set_to_sftp')
106
107
"""bzr selftest --benchmark should not run the default test suite."""
107
108
# We test this by passing a regression test name to --benchmark, which
108
109
# should result in 0 rests run.
109
old_root = TestCaseInTempDir.TEST_ROOT
110
old_root = TestCaseWithMemoryTransport.TEST_ROOT
111
TestCaseInTempDir.TEST_ROOT = None
112
TestCaseWithMemoryTransport.TEST_ROOT = None
112
113
out, err = self.run_bzr('selftest', '--benchmark', 'workingtree_implementations')
114
TestCaseInTempDir.TEST_ROOT = old_root
115
TestCaseWithMemoryTransport.TEST_ROOT = old_root
115
116
self.assertContainsRe(out, 'Ran 0 tests.*\n\nOK')
116
117
self.assertEqual(
117
118
'running tests...\ntests passed\n',
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):