Skip to content
Snippets Groups Projects
Commit 0b743ec5 authored by Stefano Borini's avatar Stefano Borini
Browse files

coverage

parent 471dac40
No related branches found
No related tags found
1 merge request!138More robust logging for BDSS
from traits.api import Bool, Int, Function
from traits.api import Bool, Int, Function, Any
from force_bdss.core.data_value import DataValue
from force_bdss.api import (
......@@ -71,6 +71,12 @@ class ProbeMCOFactory(BaseMCOFactory):
raises_on_create_optimizer = Bool(False)
raises_on_create_communicator = Bool(False)
optimizer = Any()
def __init__(self, *args, **kwargs):
super(ProbeMCOFactory, self).__init__(*args, **kwargs)
self.optimizer = self.optimizer_class(self)
def get_identifier(self):
return "probe_mco"
......@@ -107,7 +113,7 @@ class ProbeMCOFactory(BaseMCOFactory):
if self.raises_on_create_optimizer:
raise Exception("ProbeMCOFactory.create_optimizer")
return self.optimizer_class(self)
return self.optimizer
def parameter_factories(self):
return [ProbeParameterFactory(mco_factory=self)]
......@@ -175,3 +175,33 @@ class TestCoreMCODriver(unittest.TestCase):
"'force.bdss.enthought.plugin.test.v0'. "
"An exception was raised. This might "
'indicate a programming error in the plugin.'),)
with LogCapture() as capture:
with self.assertRaises(SystemExit):
driver.application_started()
def test_mco_run_exception(self):
def run_func(*args, **kwargs):
raise Exception("run_func")
driver = CoreMCODriver(
application=self.mock_application,
)
registry = self.factory_registry_plugin
mco_factory = registry.mco_factories[0]
mco_factory.optimizer.run_function = run_func
with LogCapture() as capture:
with self.assertRaises(SystemExit):
driver.application_started()
capture.check(('force_bdss.core_mco_driver',
'ERROR',
'Method run() of MCO with id '
"'force.bdss.enthought.plugin.test.v0"
".factory.probe_mco' from plugin "
"'force.bdss.enthought.plugin.test.v0'"
" raised exception. This might indicate "
'a programming error in the plugin.'),)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment