fix mutable arguments in tests

This commit is contained in:
Bjoern Gruening
2021-01-02 18:48:31 +00:00
committed by Nicola Soranzo
parent 47ba60025f
commit dfba28a443
7 changed files with 23 additions and 11 deletions
+3 -2
View File
@@ -23,10 +23,11 @@ TOOL_TYPES_NO_TEST = (DataManagerTool, )
class ToolTestCase(DrivenFunctionalTestCase):
"""Abstract test case that runs tests based on a `galaxy.tools.test.ToolTest`."""
def do_it(self, tool_id=None, tool_version=None, test_index=0, resource_parameters={}):
def do_it(self, tool_id=None, tool_version=None, test_index=0, resource_parameters=None):
"""
Run through a tool test case.
"""
resource_parameters = resource_parameters or {}
if tool_id is None:
tool_id = self.tool_id
assert tool_id
@@ -71,7 +72,7 @@ def build_tests(app=None,
G = globals()
# Eliminate all previous tests from G.
for key, val in G.copy().items():
for key in G.copy().keys():
if key.startswith('TestForTool_'):
del G[key]
+4 -2
View File
@@ -19,10 +19,12 @@ JOB_RESUBMISSION_PULSAR_JOB_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "resubm
class _BaseResubmissionIntegerationTestCase(integration_util.IntegrationTestCase):
framework_tool_and_types = True
def _assert_job_passes(self, tool_id="exit_code_oom", resource_parameters={}):
def _assert_job_passes(self, tool_id="exit_code_oom", resource_parameters=None):
resource_parameters = resource_parameters or {}
self._run_tool_test(tool_id, resource_parameters=resource_parameters)
def _assert_job_fails(self, tool_id="exit_code_oom", resource_parameters={}):
def _assert_job_fails(self, tool_id="exit_code_oom", resource_parameters=None):
resource_parameters = resource_parameters or {}
exception_thrown = False
try:
self._run_tool_test(tool_id, resource_parameters=resource_parameters)
+2 -1
View File
@@ -143,7 +143,8 @@ def __mapper(tool_job_destination=TOOL_JOB_DESTINATION):
return mapper
def __dynamic_destination(params={}):
def __dynamic_destination(params=None):
params = params or {}
return JobDestination(runner="dynamic", params=params)
+4 -2
View File
@@ -117,7 +117,7 @@ class DefaultToolActionTestCase(unittest.TestCase, tools_support.UsesApp, tools_
self._simple_execute()
except UserActivationRequiredException:
return
assert False, "Tool execution succeeded for inactive user!"
raise AssertionError("Tool execution succeeded for inactive user!")
def __add_dataset(self, state='ok'):
hda = model.HistoryDatasetAssociation()
@@ -193,7 +193,9 @@ def test_determine_output_format():
__assert_output_format_is("fastqsolexa", change_on_metadata_output, [("i1", "txt"), ("i2", "txt")])
def __assert_output_format_is(expected, output, input_extensions=[], param_context=[], add_collection=False):
def __assert_output_format_is(expected, output, input_extensions=None, param_context=None, add_collection=False):
input_extensions = input_extensions or {}
param_context = param_context or {}
inputs = {}
last_ext = "data"
i = 1
@@ -386,7 +386,8 @@ class CollectPrimaryDatasetsTestCase(unittest.TestCase, tools_support.UsesApp, t
self.job.history = self.history
self.outputs = {DEFAULT_TOOL_OUTPUT: self.hda}
def _new_history(self, hdas=[], flush=True):
def _new_history(self, hdas=None, flush=True):
hdas = hdas or []
history = model.History()
self.app.model.context.add(history)
for hda in hdas:
+6 -2
View File
@@ -233,10 +233,14 @@ class TestComputeEnvironment(SimpleComputeEnvironment):
self,
new_file_path,
working_directory,
input_paths=['/galaxy/files/dataset_1.dat'],
output_paths=['/galaxy/files/dataset_2.dat'],
input_paths=None,
output_paths=None,
unstructured_path_rewrites=None
):
if input_paths is None:
input_paths = ['/galaxy/files/dataset_1.dat']
if output_paths is None:
output_paths = ['/galaxy/files/dataset_2.dat']
self._new_file_path = new_file_path
self._working_directory = working_directory
self._input_paths = input_paths
@@ -218,7 +218,8 @@ class MockModuleInjector:
def __init__(self, progress):
self.progress = progress
def inject(self, step, step_args={}):
def inject(self, step, step_args=None):
step_args = step_args or {}
step.module = MockModule(self.progress)