Fix unit tests to be executed inside a chroot
When running unit tests inside a chroot (or a container), tests.plugins.test_dom0_pluginlib.PluginlibDom0.test_configure_logging failed because it was trying to open /dev/log, which does not exist. Fixing by mocking the _connect_unixsocket call in logging.handlers.SysLogHandler. Change-Id: Ibbbb4c71d60f1773ea9b686ae73a0f9b4ce2cfe7 Closes-Bug: #1680807
This commit is contained in:
@@ -38,6 +38,9 @@ class PluginlibDom0(plugin_test.PluginTestBase):
|
||||
self.dom0_pluginlib.logging.handlers.SysLogHandler, 'setFormatter')
|
||||
mock_Logger_addHandler = self.mock_patch_object(
|
||||
self.dom0_pluginlib.logging.Logger, 'addHandler')
|
||||
mock_socket = self.mock_patch_object(
|
||||
self.dom0_pluginlib.logging.handlers.SysLogHandler,
|
||||
'_connect_unixsocket')
|
||||
|
||||
self.dom0_pluginlib.configure_logging(name)
|
||||
|
||||
@@ -46,6 +49,7 @@ class PluginlibDom0(plugin_test.PluginTestBase):
|
||||
self.assertTrue(mock_Formatter.called)
|
||||
self.assertTrue(mock_sysh_setFormatter.called)
|
||||
self.assertTrue(mock_Logger_addHandler.called)
|
||||
self.assertTrue(mock_socket.called)
|
||||
|
||||
def test_exists_ok(self):
|
||||
fake_args = {'k1': 'v1'}
|
||||
|
||||
Reference in New Issue
Block a user