def test_fail(self): """Test failing with NotInstalledError.""" self.mock.execute.side_effect = common.NotInstalledError('gsutil') with self.assertRaises(common.GsutilNotInstalledError): common.gsutil('test', cwd='source') self.mock.execute.assert_called_once_with('gsutil', 'test', cwd='source')
def test_check_binary_fail(self): """Test check_binary fail.""" self.mock.check_binary.side_effect = common.NotInstalledError('cmd') with self.assertRaises(common.NotInstalledError) as cm: common.execute('cmd', 'aaa', '~/working/directory') self.assert_exact_calls(self.mock.check_binary, [mock.call('cmd', '~/working/directory')]) self.assertEqual(common.NotInstalledError.MESSAGE.format(binary='cmd'), cm.exception.message)
def test_check_binary_fail(self): """Test check_binary fail.""" self.mock.check_binary.side_effect = common.NotInstalledError('cmd') with self.assertRaises(common.NotInstalledError) as cm: common.execute('cmd', 'aaa', '~/working/directory') self.assert_exact_calls(self.mock.check_binary, [mock.call('cmd', '~/working/directory')]) self.assertEqual( 'cmd is not found. Please install it or ensure the path is correct.', cm.exception.message)
def __enter__(self): if self.disable_xvfb: return None self.display = xvfbwrapper.Xvfb(width=1280, height=1024) self.display.start() for i in self.display.xvfb_cmd: if i.startswith(':'): display_name = i break logger.info( 'Starting the blackbox window manager in a virtual display.') try: self.blackbox = subprocess.Popen(['blackbox'], env={'DISPLAY': display_name}) except OSError, e: if str(e) == '[Errno 2] No such file or directory': raise common.NotInstalledError('blackbox') raise