mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Store toolbox in test_case._toolbox
Apparently accessing double-underscore variables in threads leads to name-mangling issues, so effectively updating test_case.__toolbox wouldn't be reflected outside of the watcher thread. We previously used self.app.toolbox which circumenvented this issue. It is possible that `check_tool_errors` / `check_no_tool_errors` were accessing the old toolbox, unless the watching thread happened to fire between function definition and assert, and that's probably why increasing the number of trials had no effect.
This commit is contained in:
@@ -51,11 +51,9 @@ class BaseToolBoxTestCase(unittest.TestCase, UsesApp, UsesTools):
|
||||
|
||||
@property
|
||||
def toolbox(self):
|
||||
if self.__toolbox is None:
|
||||
self.__toolbox = SimplifiedToolBox(self)
|
||||
# wire app with this new toolbox
|
||||
self.app.toolbox = self.__toolbox
|
||||
return self.__toolbox
|
||||
if self._toolbox is None:
|
||||
self.app.toolbox = self._toolbox = SimplifiedToolBox(self)
|
||||
return self._toolbox
|
||||
|
||||
def setUp(self):
|
||||
self.reindexed = False
|
||||
@@ -67,7 +65,7 @@ class BaseToolBoxTestCase(unittest.TestCase, UsesApp, UsesTools):
|
||||
itp_config = os.path.join(self.test_directory, "integrated_tool_panel.xml")
|
||||
self.app.config.integrated_tool_panel_config = itp_config
|
||||
self.app.watchers = ConfigWatchers(self.app)
|
||||
self.__toolbox = None
|
||||
self._toolbox = None
|
||||
self.config_files = []
|
||||
|
||||
def _repo_install(self, changeset, config_filename=None):
|
||||
@@ -197,7 +195,7 @@ class ToolBoxTestCase(BaseToolBoxTestCase):
|
||||
macro_out.write(SIMPLE_MACRO.substitute(tool_version="3.0"))
|
||||
|
||||
def check_tool_macro():
|
||||
tool = self.app.toolbox.get_tool("tool_with_macro")
|
||||
tool = self.toolbox.get_tool("tool_with_macro")
|
||||
assert tool.version == "3.0"
|
||||
|
||||
self._try_until_no_errors(check_tool_macro)
|
||||
@@ -216,7 +214,7 @@ class ToolBoxTestCase(BaseToolBoxTestCase):
|
||||
out.write('certainly not a valid tool')
|
||||
|
||||
def check_tool_errors():
|
||||
tool = self.app.toolbox.get_tool("test_tool")
|
||||
tool = self.toolbox.get_tool("test_tool")
|
||||
assert tool is not None
|
||||
assert tool.version == "1.0"
|
||||
assert tool.tool_errors == 'Current on-disk tool is not valid'
|
||||
@@ -227,7 +225,7 @@ class ToolBoxTestCase(BaseToolBoxTestCase):
|
||||
self._init_tool(filename="simple_tool.xml", version="2.0")
|
||||
|
||||
def check_no_tool_errors():
|
||||
tool = self.app.toolbox.get_tool("test_tool")
|
||||
tool = self.toolbox.get_tool("test_tool")
|
||||
assert tool is not None
|
||||
assert tool.version == "2.0"
|
||||
assert tool.tool_errors is None
|
||||
@@ -562,4 +560,4 @@ class SimplifiedToolBox(ToolBox):
|
||||
|
||||
def reload_callback(test_case):
|
||||
test_case.app.tool_cache.cleanup()
|
||||
test_case.__toolbox = test_case.app.toolbox = SimplifiedToolBox(test_case)
|
||||
test_case._toolbox = test_case.app.toolbox = SimplifiedToolBox(test_case)
|
||||
|
||||
Reference in New Issue
Block a user