human
Complete the below
def build_tests(tmp_dir=None, testing_shed_tools=False, master_api_key=None, user_api_key=None):

    ''''If the module level variable `data_managers` is set, generate `DataManagerToolTestCase`
    classes for all of its tests and put them into this modules globals() so
    they can be discovered by nose.'
    '''
assistant
#Here is the Python code you requested.
    if (data_managers is None):
        log.warning('data_managers    was    not    set    for    Data    Manager    functional    testing.    Will    not    test.')
        return
    G = globals()
    for (key, val) in G.items():
        if key.startswith('TestForDataManagerTool_'):
            del G[key]
    for (data_table_name, data_table) in data_managers.app.tool_data_tables.get_tables().items():
        for (filename, value) in list(data_table.filenames.items()):
            new_filename = tempfile.NamedTemporaryFile(prefix=os.path.basename(filename), dir=tmp_dir).name
            try:
                shutil.copy(filename, new_filename)
            except IOError as e:
                log.warning("Failed    to    copy    '%s'    to    '%s',    will    create    empty    file    at    '%s':    %s", filename, new_filename, new_filename, e)
                open(new_filename, 'wb').close()
            if ('filename' in value):
                value['filename'] = new_filename
            del data_table.filenames[filename]
            data_table.filenames[new_filename] = value
    for (i, (data_manager_id, data_manager)) in enumerate(data_managers.data_managers.items()):
        tool = data_manager.tool
        if (not tool):
            log.warning('No    Tool    has    been    specified    for    Data    Manager:    %s', data_manager_id)
        if tool.tests:
            shed_tool_id = (None if (not testing_shed_tools) else tool.id)
            name = ('TestForDataManagerTool_' + data_manager_id.replace('    ', '_'))
            baseclasses = (DataManagerToolTestCase,)
            namespace = dict()
            for (j, testdef) in enumerate(tool.tests):
                def make_test_method(td):
                    def test_tool(self):
                        self.do_it(td)
                    return test_tool
                test_method = make_test_method(testdef)
                test_method.__doc__ = ('%s    (    %s    )    >    %s' % (tool.name, tool.id, testdef.name))
               ...