From 9b1832abb11b79a244e0505b4afc059ba894d944 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Mon, 25 Sep 2017 19:42:33 +0100 Subject: [PATCH] Fix import order for cron/, scripts/ and test/ --- .ci/flake8_lint_include_list.txt | 185 +----------------- cron/build_chrom_db.py | 2 +- lib/galaxy/tools/toolbox/filters/__init__.py | 2 +- lib/galaxy/visualization/plugins/plugin.py | 15 +- scripts/api/data_manager_example_execute.py | 4 +- scripts/api/display.py | 2 +- scripts/api/search.py | 4 +- scripts/dump_tour.py | 2 +- scripts/edam_mapping.py | 2 +- scripts/fetch_eggs.py | 7 +- scripts/grt/export.py | 15 +- scripts/grt/upload.py | 5 +- scripts/manage_tool_dependencies.py | 2 +- scripts/microbes/BeautifulSoup.py | 7 +- scripts/microbes/harvest_bacteria.py | 7 +- scripts/paster.py | 2 +- scripts/rst2html.py | 6 +- scripts/summarize_timings.py | 2 +- scripts/tool_shed/api/export.py | 2 +- .../api/get_filtered_repository_revisions.py | 2 +- .../bootstrap_tool_shed/bootstrap_util.py | 2 +- .../create_user_with_api_key.py | 5 +- ...deprecate_repositories_without_metadata.py | 8 +- scripts/tools/maf/check_loc_file.py | 6 +- test/api/test_api_batch.py | 2 +- test/api/test_authenticate.py | 2 +- test/api/test_datatypes.py | 2 +- test/api/test_histories.py | 10 +- test/api/test_history_contents.py | 8 +- test/api/test_pages.py | 2 +- test/api/test_tools.py | 2 +- test/api/test_users.py | 7 +- test/api/test_visualizations.py | 4 +- test/api/test_workflows.py | 4 +- test/base/populators.py | 6 +- test/functional/twilltestcase.py | 2 +- test/galaxy_selenium/data.py | 3 +- test/galaxy_selenium/has_driver.py | 6 +- test/galaxy_selenium/navigates_galaxy.py | 7 +- test/manual/workflows_scaling.py | 4 +- test/selenium_tests/framework.py | 23 +-- test/selenium_tests/test_anon_history.py | 6 +- .../test_collection_builders.py | 6 +- .../test_history_dataset_state.py | 2 +- test/selenium_tests/test_history_options.py | 6 +- test/selenium_tests/test_history_panel.py | 6 +- test/selenium_tests/test_history_sharing.py | 6 +- test/selenium_tests/test_login.py | 6 +- test/selenium_tests/test_sizzle_loading.py | 6 +- test/selenium_tests/test_stock_tours.py | 8 +- test/selenium_tests/test_tool_form.py | 6 +- test/selenium_tests/test_uploads.py | 2 +- test/selenium_tests/test_workflow_editor.py | 11 +- test/selenium_tests/test_workflow_run.py | 11 +- test/shed_functional/base/test_db_util.py | 8 +- test/shed_functional/base/twilltestcase.py | 4 +- test/unit/__init__.py | 0 .../dataproviders/test_base_dataproviders.py | 6 +- test/unit/jobs/test_job_wrapper.py | 2 +- test/unit/jobs/test_runner_local.py | 2 +- test/unit/managers/base.py | 6 +- test/unit/managers/test_HistoryManager.py | 7 +- .../test_installed_repository_manager.py | 3 +- .../unit/shed_unit/test_tool_panel_manager.py | 3 +- test/unit/tools/test_actions.py | 3 +- .../tools/test_collect_primary_datasets.py | 2 +- test/unit/tools/test_column_parameters.py | 3 +- test/unit/tools/test_data_parameters.py | 8 +- test/unit/tools/test_dataset_matcher.py | 4 +- test/unit/tools/test_evaluation.py | 3 +- test/unit/tools/test_execution.py | 3 +- test/unit/tools/test_history_imp_exp.py | 5 +- test/unit/tools/test_parameter_parsing.py | 5 +- test/unit/tools/test_toolbox.py | 6 +- test/unit/tools/test_toolbox_filters.py | 3 +- .../plugins/test_VisualizationPlugin.py | 7 +- .../plugins/test_VisualizationsRegistry.py | 7 +- test/unit/web/framework/test_webapp.py | 6 +- 78 files changed, 205 insertions(+), 373 deletions(-) create mode 100644 test/unit/__init__.py diff --git a/.ci/flake8_lint_include_list.txt b/.ci/flake8_lint_include_list.txt index 4cb3e453782..6d90bc4ab6f 100644 --- a/.ci/flake8_lint_include_list.txt +++ b/.ci/flake8_lint_include_list.txt @@ -1,9 +1,6 @@ client/galaxy/style/source_material/circle.py contrib/ -cron/add_manual_builds.py -cron/cleanup_datasets.py -cron/parse_builds_3_sites.py -cron/parse_builds.py +cron/ doc/parse_gx_xsd.py lib/galaxy/actions/ lib/galaxy/auth/ @@ -77,6 +74,7 @@ lib/galaxy/visualization/genome/ lib/galaxy/visualization/genomes.py lib/galaxy/visualization/__init__.py lib/galaxy/visualization/plugins/__init__.py +lib/galaxy/visualization/plugins/plugin.py lib/galaxy/visualization/plugins/utils.py lib/galaxy/visualization/tracks/ lib/galaxy/web/base/ @@ -152,182 +150,7 @@ lib/log_tempfile.py lib/mimeparse.py lib/psyco_full.py lib/tool_shed/ -scripts/api/common.py -scripts/api/copy_hda_to_library_folder.py -scripts/api/create.py -scripts/api/delete.py -scripts/api/example_watch_folder.py -scripts/api/filter_failed_datasets_from_collection.py -scripts/api/form_create_from_xml.py -scripts/api/history_create_history.py -scripts/api/history_delete_history.py -scripts/api/import_library_dataset_to_history.py -scripts/api/import_workflows_from_installed_tool_shed_repository.py -scripts/api/install_tool_shed_repositories.py -scripts/api/library_create_folder.py -scripts/api/library_create_library.py -scripts/api/library_upload_dir.py -scripts/api/library_upload_from_import_dir.py -scripts/api/load_data_with_metadata.py -scripts/api/repair_tool_shed_repository.py -scripts/api/requests_update_state.py -scripts/api/request_type_create_from_xml.py -scripts/api/reset_metadata_on_installed_repositories.py -scripts/api/sample_dataset_update_status.py -scripts/api/sample_update_state.py -scripts/api/sequencer_configuration_create.py -scripts/api/update.py -scripts/api/upload_to_history.py -scripts/api/workflow_delete.py -scripts/api/workflow_execute_parameters.py -scripts/api/workflow_execute.py -scripts/api/workflow_import_from_file_rpark.py -scripts/api/workflow_import.py -scripts/auth/ -scripts/bootstrap_history.py -scripts/build_toolbox.py -scripts/build_universe_config.py -scripts/check_galaxy.py -scripts/check_python.py -scripts/cleanup_datasets/ -scripts/communication/ -scripts/create_db.py -scripts/data_libraries/ -scripts/db_shell.py -scripts/drmaa_external_killer.py -scripts/drmaa_external_runner.py -scripts/external_chown_script.py -scripts/extract_dataset_part.py -scripts/extract_toolbox_sections.py -scripts/functional_tests.py -scripts/get_platforms.py -scripts/helper.py -scripts/__init__.py -scripts/loc_files/ -scripts/manage_db.py -scripts/manage_tools.py -scripts/metagenomics/ -scripts/microbes/create_bacteria_loc_file.py -scripts/microbes/create_bacteria_table.py -scripts/microbes/create_nib_seq_loc_file.py -scripts/microbes/get_builds_lengths.py -scripts/microbes/ncbi_to_ucsc.py -scripts/microbes/util.py -scripts/migrate_tools/ -scripts/nosetests.py -scripts/others/ -scripts/runtime_stats.py -scripts/secret_decoder_ring.py -scripts/set_dataset_sizes.py -scripts/set_user_disk_usage.py -scripts/sync_reports_config.py -scripts/tool_shed/api/add_repository_registry_entry.py -scripts/tool_shed/api/common.py -scripts/tool_shed/api/create_categories.py -scripts/tool_shed/api/create_users.py -scripts/tool_shed/api/import_capsule.py -scripts/tool_shed/api/remove_repository_registry_entry.py -scripts/tool_shed/api/reset_metadata_on_repositories.py -scripts/tool_shed/api/tool_shed_repository_revision_update.py -scripts/tool_shed/build_ts_whoosh_index.py -scripts/tool_shed/check_download_urls.py -scripts/tool_shed/check_filesystem_for_empty_tool_dependency_installation_paths.py -scripts/tool_shed/clean_up_tool_dependency_directory.py -scripts/tool_shed/migrate_tools_to_repositories.py -scripts/tool_shed/show_tool_dependency_installation_dir_contents.py -scripts/tools/re_escape_output.py -test/api/__init__.py -test/api/test_dataset_collections.py -test/api/test_datasets.py -test/api/test_framework.py -test/api/test_history_contents_provenance.py -test/api/test_jobs.py -test/api/test_libraries.py -test/api/test_page_revisions.py -test/api/test_search.py -test/api/test_tool_data.py -test/api/test_tours.py -test/api/test_workflow_extraction.py -test/api/test_workflows_from_yaml.py -test/base/api_asserts.py -test/base/api.py -test/base/api_util.py -test/base/__init__.py -test/base/instrument.py -test/base/integration_util.py -test/base/interactor.py -test/base/nose_util.py -test/base/test_logging.py -test/base/tool_shed_util.py -test/base/twilltestcase.py -test/base/workflows_format_2/ -test/casperjs/ -test/functional/database_contexts.py -test/functional/__init__.py -test/functional/test_data_managers.py -test/functional/tool-data/ -test/functional/tools/ -test/integration/ -test/manual/__init__.py -test/shed_functional/base/common.py -test/shed_functional/base/__init__.py -test/shed_functional/functional/ -test/shed_functional/functional_tests.py -test/shed_functional/__init__.py -test/unit/dataset_collections/ -test/unit/datatypes/dataproviders/__init__.py -test/unit/datatypes/dataproviders/test_line_dataproviders.py -test/unit/datatypes/__init__.py -test/unit/datatypes/test_data.py -test/unit/jobs/dynamic_tool_destination/ -test/unit/jobs/__init__.py -test/unit/jobs/test_command_factory.py -test/unit/jobs/test_datasets.py -test/unit/jobs/test_job_configuration.py -test/unit/jobs/test_job_output_checker.py -test/unit/jobs/test_mapper.py -test/unit/jobs/test_rule_helper.py -test/unit/jobs/test_rules/ -test/unit/jobs/test_runner_params.py -test/unit/managers/__init__.py -test/unit/managers/test_CollectionManager.py -test/unit/managers/test_DatasetManager.py -test/unit/managers/test_HDAManager.py -test/unit/managers/test_HDCAManager.py -test/unit/managers/test_HistoryContentsManager.py -test/unit/managers/test_UserManager.py -test/unit/shed_unit/__init__.py -test/unit/shed_unit/test_fabric_util.py -test/unit/shed_unit/test_td_common_util.py -test/unit/test_galaxy_transactions.py -test/unit/test_lazy_process.py -test/unit/test_objectstore.py -test/unit/test_routes.py -test/unit/test_security_helper.py -test/unit/test_sockets.py -test/unit/test_sqlite_utils.py -test/unit/test_topsort.py -test/unit/tools/filter_modules/ -test/unit/tools/__init__.py -test/unit/tools/test_citations.py -test/unit/tools/test_conda_resolution.py -test/unit/tools/test_parsing.py -test/unit/tools/test_select_parameters.py -test/unit/tools/test_toolbox_filters.py -test/unit/tools/test_tool_dependency_description.py -test/unit/tools/test_tool_deps.py -test/unit/tools/test_tool_external_files.py -test/unit/tools/test_tool_loader.py -test/unit/tools/test_tool_panel.py -test/unit/tools/test_watcher.py -test/unit/tools/test_wrappers.py -test/unit/tools_support.py -test/unit/unittest_utils/ -test/unit/visualizations/__init__.py -test/unit/visualizations/plugins/__init__.py -test/unit/web/base/__init__.py -test/unit/web/framework/__init__.py -test/unit/web/__init__.py -test/unit/workflows/ +scripts/ +test/ tool_list.py tools/ diff --git a/cron/build_chrom_db.py b/cron/build_chrom_db.py index 4775897548f..60c79b27b9b 100644 --- a/cron/build_chrom_db.py +++ b/cron/build_chrom_db.py @@ -20,7 +20,7 @@ import sys import requests from six.moves.urllib.parse import urlencode -import parse_builds +import parse_builds # noqa: I100 def getchrominfo(url, db): diff --git a/lib/galaxy/tools/toolbox/filters/__init__.py b/lib/galaxy/tools/toolbox/filters/__init__.py index 6e638076482..5d36d24c19b 100644 --- a/lib/galaxy/tools/toolbox/filters/__init__.py +++ b/lib/galaxy/tools/toolbox/filters/__init__.py @@ -83,7 +83,7 @@ class FilterFactory(object): try: __import__(full_module_name) except ImportError: - # log.debug("Failed to load module.", exc_info=True) + # log.debug("Failed to load module %s using sys.path %s", full_module_name, sys.path, exc_info=True) continue module = sys.modules[full_module_name] if hasattr(module, function_name): diff --git a/lib/galaxy/visualization/plugins/plugin.py b/lib/galaxy/visualization/plugins/plugin.py index e1c5f0ddcfa..82ccdd701fd 100644 --- a/lib/galaxy/visualization/plugins/plugin.py +++ b/lib/galaxy/visualization/plugins/plugin.py @@ -2,17 +2,18 @@ Visualization plugins: instantiate/deserialize data and models from a query string and render a webpage based on those data. """ - -import logging import copy -import mako +import logging import os -from galaxy.managers import api_keys +import mako.lookup -from galaxy.visualization.plugins import interactive_environments -from galaxy.visualization.plugins import resource_parser -from galaxy.visualization.plugins import utils +from galaxy.managers import api_keys +from galaxy.visualization.plugins import ( + interactive_environments, + resource_parser, + utils +) log = logging.getLogger(__name__) diff --git a/scripts/api/data_manager_example_execute.py b/scripts/api/data_manager_example_execute.py index 27715ab726f..991bef50b6e 100644 --- a/scripts/api/data_manager_example_execute.py +++ b/scripts/api/data_manager_example_execute.py @@ -4,11 +4,13 @@ # Script makes the naive assumption that dbkey==sequence id, which in many cases is not true nor desired # *** This script is not recommended for use as-is on a production server *** from __future__ import print_function + import optparse import time + from six.moves.urllib.parse import urljoin -from common import get, post +from common import get, post # noqa: I100 DEFAULT_SLEEP_TIME = 3 FETCH_GENOME_TOOL_ID = 'testtoolshed.g2.bx.psu.edu/repos/blankenberg/data_manager_fetch_genome_all_fasta/data_manager_fetch_genome_all_fasta/0.0.1' diff --git a/scripts/api/display.py b/scripts/api/display.py index bcf3885641c..d6fe219b3de 100755 --- a/scripts/api/display.py +++ b/scripts/api/display.py @@ -6,7 +6,7 @@ import sys from six.moves.urllib.error import URLError -from common import display +from common import display # noqa: I100 try: display(*sys.argv[1:3]) diff --git a/scripts/api/search.py b/scripts/api/search.py index bbb905d621d..73fc22b0451 100644 --- a/scripts/api/search.py +++ b/scripts/api/search.py @@ -2,10 +2,12 @@ Sample script for Galaxy Search API """ from __future__ import print_function + import json -import requests import sys +import requests + class RemoteGalaxy(object): diff --git a/scripts/dump_tour.py b/scripts/dump_tour.py index dde0e8e556f..b13020581cb 100755 --- a/scripts/dump_tour.py +++ b/scripts/dump_tour.py @@ -2,8 +2,8 @@ import argparse import datetime import os -import time import sys +import time sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'test'))) diff --git a/scripts/edam_mapping.py b/scripts/edam_mapping.py index f483db8c1f5..c3756ad97c7 100644 --- a/scripts/edam_mapping.py +++ b/scripts/edam_mapping.py @@ -22,8 +22,8 @@ import requests sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'lib'))) -import galaxy.model import galaxy.datatypes.registry +import galaxy.model SCRIPTS_DIR = os.path.dirname(__file__) PROJECT_DIR = os.path.abspath(os.path.join(SCRIPTS_DIR, os.pardir)) diff --git a/scripts/fetch_eggs.py b/scripts/fetch_eggs.py index 5236a733266..61451a6ef1b 100755 --- a/scripts/fetch_eggs.py +++ b/scripts/fetch_eggs.py @@ -1,7 +1,12 @@ #!/usr/bin/env python from __future__ import print_function + from os import pardir -from os.path import join, abspath, dirname +from os.path import ( + abspath, + dirname, + join +) from sys import exit msg = """ diff --git a/scripts/grt/export.py b/scripts/grt/export.py index da8048522f2..f5a3480c14b 100644 --- a/scripts/grt/export.py +++ b/scripts/grt/export.py @@ -4,25 +4,24 @@ See doc/source/admin/grt.rst for more detailed usage information. """ import argparse -import tarfile import json +import logging import os -import sqlalchemy as sa import subprocess import sys +import tarfile import time -import yaml -import logging - from collections import defaultdict -sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'lib'))) +import sqlalchemy as sa +import yaml -from galaxy.util.properties import load_app_properties +sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'lib'))) import galaxy import galaxy.config -from galaxy.objectstore import build_object_store_from_config from galaxy.model import mapping +from galaxy.objectstore import build_object_store_from_config +from galaxy.util.properties import load_app_properties sample_config = os.path.abspath(os.path.join(os.path.dirname(__file__), 'grt.yml.sample')) default_config = os.path.abspath(os.path.join(os.path.dirname(__file__), 'grt.yml')) diff --git a/scripts/grt/upload.py b/scripts/grt/upload.py index a93efb86a62..8ec619fc5b7 100644 --- a/scripts/grt/upload.py +++ b/scripts/grt/upload.py @@ -4,11 +4,12 @@ See doc/source/admin/grt.rst for more detailed usage information. """ import argparse +import logging import os import sys -import yaml -import logging + import requests +import yaml sample_config = os.path.abspath(os.path.join(os.path.dirname(__file__), 'grt.yml.sample')) default_config = os.path.abspath(os.path.join(os.path.dirname(__file__), 'grt.yml')) diff --git a/scripts/manage_tool_dependencies.py b/scripts/manage_tool_dependencies.py index 45a89cc82ae..40e09217d48 100644 --- a/scripts/manage_tool_dependencies.py +++ b/scripts/manage_tool_dependencies.py @@ -4,7 +4,6 @@ import sys sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'lib'))) -from galaxy.util.properties import find_config_file, load_app_properties from galaxy.config import ( configure_logging, find_path, @@ -12,6 +11,7 @@ from galaxy.config import ( parse_dependency_options, ) from galaxy.tools.deps import CachedDependencyManager, DependencyManager, NullDependencyManager +from galaxy.util.properties import find_config_file, load_app_properties DESCRIPTION = "Script to manage tool dependencies (with focus on a Conda environments)." diff --git a/scripts/microbes/BeautifulSoup.py b/scripts/microbes/BeautifulSoup.py index cd104595187..b9262d7a828 100644 --- a/scripts/microbes/BeautifulSoup.py +++ b/scripts/microbes/BeautifulSoup.py @@ -45,12 +45,15 @@ from __future__ import generators import codecs import re +import sgmllib import string import sys import types -import sgmllib from htmlentitydefs import name2codepoint -from sgmllib import SGMLParser, SGMLParseError +from sgmllib import ( + SGMLParseError, + SGMLParser +) __author__ = "Leonard Richardson (crummy.com)" __contributors__ = ["Sam Ruby (intertwingly.net)", diff --git a/scripts/microbes/harvest_bacteria.py b/scripts/microbes/harvest_bacteria.py index 3226dec78ce..762d9cfa821 100644 --- a/scripts/microbes/harvest_bacteria.py +++ b/scripts/microbes/harvest_bacteria.py @@ -12,7 +12,12 @@ from urllib import urlretrieve import requests from BeautifulSoup import BeautifulSoup -from util import get_bed_from_genbank, get_bed_from_glimmer3, get_bed_from_GeneMarkHMM, get_bed_from_GeneMark +from util import ( + get_bed_from_genbank, + get_bed_from_GeneMark, + get_bed_from_GeneMarkHMM, + get_bed_from_glimmer3 +) assert sys.version_info[:2] >= (2, 4) diff --git a/scripts/paster.py b/scripts/paster.py index e1548b3ed6e..861a98075ae 100755 --- a/scripts/paster.py +++ b/scripts/paster.py @@ -11,7 +11,7 @@ sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pa from galaxy.util.pastescript import serve -from check_python import check_python +from check_python import check_python # noqa: I100 # ensure supported version try: diff --git a/scripts/rst2html.py b/scripts/rst2html.py index ef6e1fcc20a..409d8e26c2f 100755 --- a/scripts/rst2html.py +++ b/scripts/rst2html.py @@ -16,8 +16,10 @@ try: except: pass -from docutils.core import publish_cmdline, default_description - +from docutils.core import ( + default_description, + publish_cmdline +) description = ('Generates (X)HTML documents from standalone reStructuredText ' 'sources. ' + default_description) diff --git a/scripts/summarize_timings.py b/scripts/summarize_timings.py index 5cf4295bc79..cfa1169594b 100644 --- a/scripts/summarize_timings.py +++ b/scripts/summarize_timings.py @@ -1,8 +1,8 @@ """Script to parse timings out of a Galaxy log and summarize.""" from __future__ import print_function -from argparse import ArgumentParser import re +from argparse import ArgumentParser import numpy diff --git a/scripts/tool_shed/api/export.py b/scripts/tool_shed/api/export.py index 6a5d030c6a0..05b43f53f78 100644 --- a/scripts/tool_shed/api/export.py +++ b/scripts/tool_shed/api/export.py @@ -17,7 +17,7 @@ import requests sys.path.insert(1, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, 'lib')) from tool_shed.util import basic_util -from common import display, submit +from common import display, submit # noqa: I100 CAPSULE_FILENAME = 'capsule' CAPSULE_WITH_DEPENDENCIES_FILENAME = 'capsule_with_dependencies' diff --git a/scripts/tool_shed/api/get_filtered_repository_revisions.py b/scripts/tool_shed/api/get_filtered_repository_revisions.py index a59911fc40c..b5805e697bc 100644 --- a/scripts/tool_shed/api/get_filtered_repository_revisions.py +++ b/scripts/tool_shed/api/get_filtered_repository_revisions.py @@ -28,7 +28,7 @@ sys.path.insert(1, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, from galaxy.util import asbool from tool_shed.util import hg_util -from common import get_api_url, get_repository_dict, json_from_url +from common import get_api_url, get_repository_dict, json_from_url # noqa: I100 def main(options): diff --git a/scripts/tool_shed/bootstrap_tool_shed/bootstrap_util.py b/scripts/tool_shed/bootstrap_tool_shed/bootstrap_util.py index 2a899238b88..6d91d9bf87a 100755 --- a/scripts/tool_shed/bootstrap_tool_shed/bootstrap_util.py +++ b/scripts/tool_shed/bootstrap_tool_shed/bootstrap_util.py @@ -1,6 +1,6 @@ #!/usr/bin/python -import optparse import ConfigParser +import optparse import os import sys diff --git a/scripts/tool_shed/bootstrap_tool_shed/create_user_with_api_key.py b/scripts/tool_shed/bootstrap_tool_shed/create_user_with_api_key.py index 4d1d20658ad..001c001a87d 100644 --- a/scripts/tool_shed/bootstrap_tool_shed/create_user_with_api_key.py +++ b/scripts/tool_shed/bootstrap_tool_shed/create_user_with_api_key.py @@ -2,10 +2,10 @@ import ConfigParser import logging +import optparse import os import re import sys -import optparse sys.path.insert(1, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, 'lib')) sys.path.insert(1, os.path.join(os.path.dirname(__file__))) @@ -13,7 +13,8 @@ sys.path.insert(1, os.path.join(os.path.dirname(__file__))) import galaxy.webapps.tool_shed.config as tool_shed_config from galaxy.web import security from galaxy.webapps.tool_shed.model import mapping -from bootstrap_util import admin_user_info + +from bootstrap_util import admin_user_info # noqa: I100 log = logging.getLogger(__name__) diff --git a/scripts/tool_shed/deprecate_repositories_without_metadata.py b/scripts/tool_shed/deprecate_repositories_without_metadata.py index 95357ceafbe..1a31604e6e1 100644 --- a/scripts/tool_shed/deprecate_repositories_without_metadata.py +++ b/scripts/tool_shed/deprecate_repositories_without_metadata.py @@ -8,8 +8,8 @@ import sys import textwrap import time from datetime import datetime, timedelta -from time import strftime from optparse import OptionParser +from time import strftime import sqlalchemy as sa from sqlalchemy import and_, distinct, false, not_ @@ -18,8 +18,10 @@ sys.path.insert(1, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, import galaxy.webapps.tool_shed.config as tool_shed_config import galaxy.webapps.tool_shed.model.mapping -from galaxy.util import send_mail as galaxy_send_mail -from galaxy.util import build_url +from galaxy.util import ( + build_url, + send_mail as galaxy_send_mail +) log = logging.getLogger() log.setLevel(10) diff --git a/scripts/tools/maf/check_loc_file.py b/scripts/tools/maf/check_loc_file.py index cc0078a238d..96be0d8f7ce 100644 --- a/scripts/tools/maf/check_loc_file.py +++ b/scripts/tools/maf/check_loc_file.py @@ -1,10 +1,12 @@ # Dan Blankenberg # This script checks maf_index.loc file for inconsistencies between what is listed as available and what is really available. # Make sure that required dependencies (e.g. galaxy_root/lib) are included in your PYTHONPATH -import bx.align.maf -from galaxy.tools.util import maf_utilities import sys +import bx.align.maf + +from galaxy.tools.util import maf_utilities + assert sys.version_info[:2] >= (2, 4) diff --git a/test/api/test_api_batch.py b/test/api/test_api_batch.py index fef24d0a87d..e7a8d1ccc39 100644 --- a/test/api/test_api_batch.py +++ b/test/api/test_api_batch.py @@ -2,7 +2,7 @@ import json from requests import post -from base import api +from base import api # noqa: I100 class ApiBatchTestCase(api.ApiTestCase): diff --git a/test/api/test_authenticate.py b/test/api/test_authenticate.py index a99e2ff4728..5e25e69426d 100644 --- a/test/api/test_authenticate.py +++ b/test/api/test_authenticate.py @@ -2,7 +2,7 @@ import base64 from requests import get -from base import api +from base import api # noqa: I100 TEST_USER_EMAIL = "auth_user_test@bx.psu.edu" TEST_USER_PASSWORD = "testpassword1" diff --git a/test/api/test_datatypes.py b/test/api/test_datatypes.py index d41cd98596b..70341332e97 100644 --- a/test/api/test_datatypes.py +++ b/test/api/test_datatypes.py @@ -2,7 +2,7 @@ import time from requests import put -from base import api +from base import api # noqa: I100 HIDDEN_DURING_UPLOAD_DATATYPE = "fli" diff --git a/test/api/test_histories.py b/test/api/test_histories.py index cf57354d342..ed26d3056f6 100644 --- a/test/api/test_histories.py +++ b/test/api/test_histories.py @@ -1,14 +1,16 @@ # -*- coding: utf-8 -*- - from requests import ( get, post, put ) -from base import api - -from base.populators import DatasetPopulator, DatasetCollectionPopulator, wait_on +from base import api # noqa: I100 +from base.populators import ( # noqa: I100 + DatasetCollectionPopulator, + DatasetPopulator, + wait_on +) class HistoriesApiTestCase(api.ApiTestCase): diff --git a/test/api/test_history_contents.py b/test/api/test_history_contents.py index c82e8cb4cdd..f395452f97c 100644 --- a/test/api/test_history_contents.py +++ b/test/api/test_history_contents.py @@ -4,8 +4,12 @@ import json from requests import delete, put -from base import api -from base.populators import DatasetCollectionPopulator, LibraryPopulator, TestsDatasets +from base import api # noqa: I100 +from base.populators import ( # noqa: I100 + DatasetCollectionPopulator, + LibraryPopulator, + TestsDatasets +) # TODO: Test anonymous access. diff --git a/test/api/test_pages.py b/test/api/test_pages.py index f0b5755eec4..8d72b0601ad 100644 --- a/test/api/test_pages.py +++ b/test/api/test_pages.py @@ -1,6 +1,6 @@ from requests import delete -from base import api +from base import api # noqa: I100 from galaxy.exceptions import error_codes diff --git a/test/api/test_tools.py b/test/api/test_tools.py index 0dcfe546bac..7b7e7cd878b 100644 --- a/test/api/test_tools.py +++ b/test/api/test_tools.py @@ -6,8 +6,8 @@ from base.populators import ( DatasetCollectionPopulator, DatasetPopulator, LibraryPopulator, - skip_without_tool, skip_without_datatype, + skip_without_tool, ) from galaxy.tools.verify.test_data import TestDataResolver diff --git a/test/api/test_users.py b/test/api/test_users.py index 977cac886c3..7453e3210a2 100644 --- a/test/api/test_users.py +++ b/test/api/test_users.py @@ -1,8 +1,11 @@ import json -from requests import put, get +from requests import ( + get, + put +) -from base import api +from base import api # noqa: I100 TEST_USER_EMAIL = "user_for_users_index_test@bx.psu.edu" diff --git a/test/api/test_visualizations.py b/test/api/test_visualizations.py index 7ed68af6321..702dd890c02 100644 --- a/test/api/test_visualizations.py +++ b/test/api/test_visualizations.py @@ -5,8 +5,8 @@ from requests import ( put ) -from base import api -from base.api_asserts import assert_has_keys +from base import api # noqa: I100 +from base.api_asserts import assert_has_keys # noqa: I100 INDEX_KEYS = [ 'id', 'title', 'type', 'dbkey', 'url' diff --git a/test/api/test_workflows.py b/test/api/test_workflows.py index f3c45c03368..c0162be0883 100644 --- a/test/api/test_workflows.py +++ b/test/api/test_workflows.py @@ -8,8 +8,8 @@ from uuid import uuid4 import yaml from requests import delete, put -from base import api -from base.populators import ( +from base import api # noqa: I100 +from base.populators import ( # noqa: I100 DatasetCollectionPopulator, DatasetPopulator, skip_without_tool, diff --git a/test/base/populators.py b/test/base/populators.py index e7d19e463a2..336ef523918 100644 --- a/test/base/populators.py +++ b/test/base/populators.py @@ -1,17 +1,15 @@ import contextlib import json import time - from functools import wraps from operator import itemgetter import requests - from pkg_resources import resource_string from six import StringIO -from base import api_asserts -from base.workflows_format_2 import ( +from . import api_asserts +from .workflows_format_2 import ( convert_and_import_workflow, ImporterGalaxyInterface, ) diff --git a/test/functional/twilltestcase.py b/test/functional/twilltestcase.py index 249c8a0b889..56c0aea45b8 100644 --- a/test/functional/twilltestcase.py +++ b/test/functional/twilltestcase.py @@ -15,7 +15,7 @@ from six import string_types, StringIO from six.moves.urllib.parse import urlencode, urlparse from twill.other_packages._mechanize_dist import ClientForm -from base.testcase import FunctionalTestCase +from base.testcase import FunctionalTestCase # noqa: I100 # Force twill to log to a buffer -- FIXME: Should this go to stdout and be captured by nose? buffer = StringIO() diff --git a/test/galaxy_selenium/data.py b/test/galaxy_selenium/data.py index ef15e27197b..1ed3baf0a5a 100644 --- a/test/galaxy_selenium/data.py +++ b/test/galaxy_selenium/data.py @@ -1,6 +1,5 @@ -from pkg_resources import resource_string - import yaml +from pkg_resources import resource_string data_yaml = resource_string(__name__, 'navigation-data.yml').decode("UTF-8") NAVIGATION_DATA = yaml.safe_load(data_yaml) diff --git a/test/galaxy_selenium/has_driver.py b/test/galaxy_selenium/has_driver.py index 4dca4fbe5d3..30b4a4f9e88 100644 --- a/test/galaxy_selenium/has_driver.py +++ b/test/galaxy_selenium/has_driver.py @@ -4,9 +4,9 @@ This should be mixed into classes with a self.driver and self.default_timeout attribute. """ +from selenium.common.exceptions import TimeoutException from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.by import By -from selenium.common.exceptions import TimeoutException from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as ec from selenium.webdriver.support.ui import WebDriverWait @@ -140,7 +140,7 @@ class HasDriver: ) -def execption_indicates_not_clickable(exception): +def exception_indicates_not_clickable(exception): return "not clickable" in str(exception) @@ -149,7 +149,7 @@ def exception_indicates_stale_element(exception): __all__ = ( - "execption_indicates_not_clickable", + "exception_indicates_not_clickable", "exception_indicates_stale_element", "HasDriver", "TimeoutException", diff --git a/test/galaxy_selenium/navigates_galaxy.py b/test/galaxy_selenium/navigates_galaxy.py index 8981b3779da..71a77e711ac 100644 --- a/test/galaxy_selenium/navigates_galaxy.py +++ b/test/galaxy_selenium/navigates_galaxy.py @@ -8,20 +8,19 @@ import contextlib import random import string import time - from functools import partial, wraps import requests import yaml +from . import sizzle from .data import NAVIGATION_DATA from .has_driver import ( - execption_indicates_not_clickable, + exception_indicates_not_clickable, exception_indicates_stale_element, HasDriver, TimeoutException, ) -from . import sizzle # Test case data DEFAULT_PASSWORD = '123456' @@ -50,7 +49,7 @@ def excepion_seems_to_indicate_transition(e): StaleElement exceptions (a DOM element grabbed at one step is no longer available) and "not clickable" exceptions (so perhaps a popup modal is blocking a click). """ - return exception_indicates_stale_element(e) or execption_indicates_not_clickable(e) + return exception_indicates_stale_element(e) or exception_indicates_not_clickable(e) def retry_call_during_transitions(f, attempts=RETRY_DURING_TRANSITIONS_ATTEMPTS_DEFAULT, sleep=RETRY_DURING_TRANSITIONS_SLEEP_DEFAULT, exception_check=excepion_seems_to_indicate_transition): diff --git a/test/manual/workflows_scaling.py b/test/manual/workflows_scaling.py index 69ed5514580..677eff160df 100644 --- a/test/manual/workflows_scaling.py +++ b/test/manual/workflows_scaling.py @@ -19,12 +19,12 @@ from bioblend import galaxy galaxy_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)) sys.path[1:1] = [os.path.join(galaxy_root, "lib"), os.path.join(galaxy_root, "test")] -from base.populators import ( +from base.populators import ( # noqa: I100 GiDatasetCollectionPopulator, GiDatasetPopulator, GiWorkflowPopulator, ) -from api.workflows_format_2.converter import python_to_workflow +from api.workflows_format_2.converter import python_to_workflow # noqa: I100 LONG_TIMEOUT = 1000000000 DESCRIPTION = "Script to exercise the workflow engine." diff --git a/test/selenium_tests/framework.py b/test/selenium_tests/framework.py index 01532fc8fe5..d4f318596f0 100644 --- a/test/selenium_tests/framework.py +++ b/test/selenium_tests/framework.py @@ -8,31 +8,26 @@ import os import time import traceback import unittest - from functools import partial, wraps import requests - -from galaxy_selenium import ( - driver_factory, -) -from galaxy_selenium.navigates_galaxy import NavigatesGalaxy, retry_during_transitions - try: from pyvirtualdisplay import Display except ImportError: Display = None - from six.moves.urllib.parse import urljoin -from base import populators -from base.driver_util import classproperty, DEFAULT_WEB_HOST, get_ip_address -from base.testcase import FunctionalTestCase -from base.workflows_format_2 import ( - ImporterGalaxyInterface, +from base import populators # noqa: I100 +from base.driver_util import classproperty, DEFAULT_WEB_HOST, get_ip_address # noqa: I100 +from base.testcase import FunctionalTestCase # noqa: I100 +from base.workflows_format_2 import ( # noqa: I100 convert_and_import_workflow, + ImporterGalaxyInterface, ) - +from galaxy_selenium import ( # noqa: I100 + driver_factory, +) +from galaxy_selenium.navigates_galaxy import NavigatesGalaxy, retry_during_transitions # noqa: I100 from galaxy.util import asbool DEFAULT_WAIT_TIMEOUT = 60 diff --git a/test/selenium_tests/test_anon_history.py b/test/selenium_tests/test_anon_history.py index f26b8655f44..b37c8448391 100644 --- a/test/selenium_tests/test_anon_history.py +++ b/test/selenium_tests/test_anon_history.py @@ -1,5 +1,7 @@ -from .framework import SeleniumTestCase -from .framework import selenium_test +from .framework import ( + selenium_test, + SeleniumTestCase +) class AnonymousHistoriesTestCase(SeleniumTestCase): diff --git a/test/selenium_tests/test_collection_builders.py b/test/selenium_tests/test_collection_builders.py index f63febae6b3..6b59e1070da 100644 --- a/test/selenium_tests/test_collection_builders.py +++ b/test/selenium_tests/test_collection_builders.py @@ -1,5 +1,7 @@ -from .framework import SeleniumTestCase -from .framework import selenium_test +from .framework import ( + selenium_test, + SeleniumTestCase +) class CollectionBuildersTestCase(SeleniumTestCase): diff --git a/test/selenium_tests/test_history_dataset_state.py b/test/selenium_tests/test_history_dataset_state.py index 07ecb9becf5..95b86b015de 100644 --- a/test/selenium_tests/test_history_dataset_state.py +++ b/test/selenium_tests/test_history_dataset_state.py @@ -1,6 +1,6 @@ from .framework import ( - SeleniumTestCase, selenium_test, + SeleniumTestCase, UsesHistoryItemAssertions, ) diff --git a/test/selenium_tests/test_history_options.py b/test/selenium_tests/test_history_options.py index f701f65d357..d4dad146da4 100644 --- a/test/selenium_tests/test_history_options.py +++ b/test/selenium_tests/test_history_options.py @@ -1,5 +1,7 @@ -from .framework import SeleniumTestCase -from .framework import selenium_test +from .framework import ( + selenium_test, + SeleniumTestCase +) class HistoryOptionsTestCase(SeleniumTestCase): diff --git a/test/selenium_tests/test_history_panel.py b/test/selenium_tests/test_history_panel.py index 12c514b7306..f1aae2d5026 100644 --- a/test/selenium_tests/test_history_panel.py +++ b/test/selenium_tests/test_history_panel.py @@ -1,7 +1,9 @@ import time -from .framework import SeleniumTestCase -from .framework import selenium_test +from .framework import ( + selenium_test, + SeleniumTestCase +) class HistoryPanelTestCase(SeleniumTestCase): diff --git a/test/selenium_tests/test_history_sharing.py b/test/selenium_tests/test_history_sharing.py index dc77592b02f..7129c2713ff 100644 --- a/test/selenium_tests/test_history_sharing.py +++ b/test/selenium_tests/test_history_sharing.py @@ -1,5 +1,7 @@ -from .framework import SeleniumTestCase -from .framework import selenium_test +from .framework import ( + selenium_test, + SeleniumTestCase +) # Remove hack when submit_login works more consistently. VALID_LOGIN_RETRIES = 3 diff --git a/test/selenium_tests/test_login.py b/test/selenium_tests/test_login.py index e782728ea0c..cbdac4fc3d1 100644 --- a/test/selenium_tests/test_login.py +++ b/test/selenium_tests/test_login.py @@ -1,5 +1,7 @@ -from .framework import SeleniumTestCase -from .framework import selenium_test +from .framework import ( + selenium_test, + SeleniumTestCase +) class LoginTestCase(SeleniumTestCase): diff --git a/test/selenium_tests/test_sizzle_loading.py b/test/selenium_tests/test_sizzle_loading.py index 022e6fdfb67..94fdd6bb588 100644 --- a/test/selenium_tests/test_sizzle_loading.py +++ b/test/selenium_tests/test_sizzle_loading.py @@ -1,5 +1,7 @@ -from .framework import SeleniumTestCase -from .framework import selenium_test +from .framework import ( + selenium_test, + SeleniumTestCase +) class SizzleLoadingTestCase(SeleniumTestCase): diff --git a/test/selenium_tests/test_stock_tours.py b/test/selenium_tests/test_stock_tours.py index 4e3b1059bab..66ac07a5409 100644 --- a/test/selenium_tests/test_stock_tours.py +++ b/test/selenium_tests/test_stock_tours.py @@ -1,10 +1,12 @@ import os -from .framework import SeleniumTestCase -from .framework import selenium_test - from galaxy.util import galaxy_root_path +from .framework import ( + selenium_test, + SeleniumTestCase +) + STOCK_TOURS_DIRECTORY = os.path.join(galaxy_root_path, "config", "plugins", "tours") diff --git a/test/selenium_tests/test_tool_form.py b/test/selenium_tests/test_tool_form.py index 6d726c13621..38ad877971c 100644 --- a/test/selenium_tests/test_tool_form.py +++ b/test/selenium_tests/test_tool_form.py @@ -1,11 +1,11 @@ +from galaxy_selenium.navigates_galaxy import retry_call_during_transitions + from .framework import ( - SeleniumTestCase, selenium_test, + SeleniumTestCase, UsesHistoryItemAssertions, ) -from galaxy_selenium.navigates_galaxy import retry_call_during_transitions - class ToolFormTestCase(SeleniumTestCase, UsesHistoryItemAssertions): diff --git a/test/selenium_tests/test_uploads.py b/test/selenium_tests/test_uploads.py index 7e5cdcd55d3..d9ad6cdd570 100644 --- a/test/selenium_tests/test_uploads.py +++ b/test/selenium_tests/test_uploads.py @@ -1,6 +1,6 @@ from .framework import ( - SeleniumTestCase, selenium_test, + SeleniumTestCase, UsesHistoryItemAssertions, ) diff --git a/test/selenium_tests/test_workflow_editor.py b/test/selenium_tests/test_workflow_editor.py index 458cb3c032a..d44d252bd03 100644 --- a/test/selenium_tests/test_workflow_editor.py +++ b/test/selenium_tests/test_workflow_editor.py @@ -1,17 +1,16 @@ import time +from ._workflow_fixtures import ( + WORKFLOW_SIMPLE_CAT_TWICE, + WORKFLOW_WITH_INVALID_STATE, + WORKFLOW_WITH_OLD_TOOL_VERSION, +) from .framework import ( retry_assertion_during_transitions, selenium_test, SeleniumTestCase ) -from ._workflow_fixtures import ( - WORKFLOW_SIMPLE_CAT_TWICE, - WORKFLOW_WITH_OLD_TOOL_VERSION, - WORKFLOW_WITH_INVALID_STATE, -) - class WorkflowEditorTestCase(SeleniumTestCase): diff --git a/test/selenium_tests/test_workflow_run.py b/test/selenium_tests/test_workflow_run.py index 4533ecacabf..8bdc834f7b2 100644 --- a/test/selenium_tests/test_workflow_run.py +++ b/test/selenium_tests/test_workflow_run.py @@ -1,15 +1,14 @@ import time -from .framework import ( - selenium_test, - SeleniumTestCase, - UsesHistoryItemAssertions, -) - from ._workflow_fixtures import ( WORKFLOW_SIMPLE_CAT_TWICE, WORKFLOW_WITH_OLD_TOOL_VERSION, ) +from .framework import ( + selenium_test, + SeleniumTestCase, + UsesHistoryItemAssertions, +) class WorkflowRunTestCase(SeleniumTestCase, UsesHistoryItemAssertions): diff --git a/test/shed_functional/base/test_db_util.py b/test/shed_functional/base/test_db_util.py index c9ba1356555..f1db34bc614 100644 --- a/test/shed_functional/base/test_db_util.py +++ b/test/shed_functional/base/test_db_util.py @@ -5,9 +5,11 @@ from sqlalchemy import and_, false, true import galaxy.model import galaxy.model.tool_shed_install import galaxy.webapps.tool_shed.model as model - -from base.driver_util import (galaxy_context as ga_session, - install_context as install_session, tool_shed_context as sa_session) +from base.driver_util import ( # noqa: I100 + galaxy_context as ga_session, + install_context as install_session, + tool_shed_context as sa_session +) log = logging.getLogger('test.tool_shed.test_db_util') diff --git a/test/shed_functional/base/twilltestcase.py b/test/shed_functional/base/twilltestcase.py index 0ab2da9ddf4..681e51b3a4d 100644 --- a/test/shed_functional/base/twilltestcase.py +++ b/test/shed_functional/base/twilltestcase.py @@ -15,8 +15,8 @@ from six.moves.urllib.parse import quote_plus, urlencode import galaxy.model.tool_shed_install as galaxy_model import galaxy.util import galaxy.webapps.tool_shed.util.hgweb_config -from base.tool_shed_util import repository_installation_timeout -from functional.twilltestcase import TwillTestCase +from base.tool_shed_util import repository_installation_timeout # noqa: I100 +from functional.twilltestcase import TwillTestCase # noqa: I100 from galaxy.web import security from tool_shed.util import hg_util, xml_util from tool_shed.util.encoding_util import tool_shed_encode diff --git a/test/unit/__init__.py b/test/unit/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/unit/datatypes/dataproviders/test_base_dataproviders.py b/test/unit/datatypes/dataproviders/test_base_dataproviders.py index 883e12ea2f5..e081cc41ac4 100644 --- a/test/unit/datatypes/dataproviders/test_base_dataproviders.py +++ b/test/unit/datatypes/dataproviders/test_base_dataproviders.py @@ -3,17 +3,13 @@ Unit tests for base DataProviders. .. seealso:: galaxy.datatypes.dataproviders.base """ import logging -import os.path -import sys import unittest from six import StringIO from galaxy.datatypes.dataproviders import base, exceptions -unit_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) -sys.path.insert(1, unit_root) -from unittest_utils import tempfilecache, utility +from ...unittest_utils import tempfilecache, utility log = logging.getLogger(__name__) diff --git a/test/unit/jobs/test_job_wrapper.py b/test/unit/jobs/test_job_wrapper.py index 7c64fb3faef..268daf2315f 100644 --- a/test/unit/jobs/test_job_wrapper.py +++ b/test/unit/jobs/test_job_wrapper.py @@ -14,7 +14,7 @@ from galaxy.model import ( from galaxy.tools import evaluation from galaxy.util.bunch import Bunch -from tools_support import UsesApp +from ..tools_support import UsesApp TEST_TOOL_ID = "cufftest" TEST_VERSION_COMMAND = "bwa --version" diff --git a/test/unit/jobs/test_runner_local.py b/test/unit/jobs/test_runner_local.py index 70857bb3bb6..e9c85a301c0 100644 --- a/test/unit/jobs/test_runner_local.py +++ b/test/unit/jobs/test_runner_local.py @@ -8,7 +8,7 @@ from galaxy.jobs import metrics from galaxy.jobs.runners import local from galaxy.util import bunch -from tools_support import ( +from ..tools_support import ( UsesApp, UsesTools ) diff --git a/test/unit/managers/base.py b/test/unit/managers/base.py index 5291d636e9a..c1722e3c8dd 100644 --- a/test/unit/managers/base.py +++ b/test/unit/managers/base.py @@ -3,8 +3,6 @@ from __future__ import print_function import json -import os -import sys import unittest import sqlalchemy @@ -12,9 +10,7 @@ from six import string_types from galaxy.managers.users import UserManager -unit_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) -sys.path.insert(1, unit_root) -from unittest_utils import galaxy_mock +from ..unittest_utils import galaxy_mock # ============================================================================= admin_email = 'admin@admin.admin' diff --git a/test/unit/managers/test_HistoryManager.py b/test/unit/managers/test_HistoryManager.py index 1d741400374..530295b9c82 100644 --- a/test/unit/managers/test_HistoryManager.py +++ b/test/unit/managers/test_HistoryManager.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- """ """ -import os -import sys import unittest import sqlalchemy @@ -24,11 +22,8 @@ from galaxy.managers.histories import ( HistorySerializer ) -unit_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) -sys.path.insert(1, unit_root) -from unittest_utils import galaxy_mock - from .base import BaseTestCase +from ..unittest_utils import galaxy_mock default_password = '123456' user2_data = dict(email='user2@user2.user2', username='user2', password=default_password) diff --git a/test/unit/shed_unit/test_installed_repository_manager.py b/test/unit/shed_unit/test_installed_repository_manager.py index 3fc33637363..ffd3f57ff06 100644 --- a/test/unit/shed_unit/test_installed_repository_manager.py +++ b/test/unit/shed_unit/test_installed_repository_manager.py @@ -1,5 +1,6 @@ from tool_shed.galaxy_install.installed_repository_manager import InstalledRepositoryManager -from tools.test_toolbox import BaseToolBoxTestCase + +from ..tools.test_toolbox import BaseToolBoxTestCase class InstalledRepositoryManagerTestCase(BaseToolBoxTestCase): diff --git a/test/unit/shed_unit/test_tool_panel_manager.py b/test/unit/shed_unit/test_tool_panel_manager.py index e6cab3a53cc..c3ab72fb727 100644 --- a/test/unit/shed_unit/test_tool_panel_manager.py +++ b/test/unit/shed_unit/test_tool_panel_manager.py @@ -4,7 +4,8 @@ from galaxy.util import parse_xml from tool_shed.galaxy_install.tools import tool_panel_manager from tool_shed.tools import tool_version_manager -from tools.test_toolbox import ( + +from ..tools.test_toolbox import ( BaseToolBoxTestCase, SimplifiedToolBox ) diff --git a/test/unit/tools/test_actions.py b/test/unit/tools/test_actions.py index 1978f6dd109..5d0e0d83db1 100644 --- a/test/unit/tools/test_actions.py +++ b/test/unit/tools/test_actions.py @@ -2,7 +2,6 @@ import string import unittest from xml.etree.ElementTree import XML -import tools_support from galaxy import model from galaxy.tools.actions import ( DefaultToolAction, @@ -11,6 +10,8 @@ from galaxy.tools.actions import ( ) from galaxy.tools.parser.output_objects import ToolOutput +from .. import tools_support + TEST_HANDLER_NAME = "test_handler_1" diff --git a/test/unit/tools/test_collect_primary_datasets.py b/test/unit/tools/test_collect_primary_datasets.py index b5317e1b358..9c04b3301e0 100644 --- a/test/unit/tools/test_collect_primary_datasets.py +++ b/test/unit/tools/test_collect_primary_datasets.py @@ -2,7 +2,6 @@ import json import os import unittest -import tools_support from galaxy import ( model, util @@ -10,6 +9,7 @@ from galaxy import ( from galaxy.tools.parameters.output_collect import LegacyToolProvidedMetadata, NullToolProvidedMetadata from galaxy.tools.parser import output_collection_def +from .. import tools_support DEFAULT_TOOL_OUTPUT = "out1" DEFAULT_EXTRA_NAME = "test1" diff --git a/test/unit/tools/test_column_parameters.py b/test/unit/tools/test_column_parameters.py index ab40fd07851..9df583cdfcc 100644 --- a/test/unit/tools/test_column_parameters.py +++ b/test/unit/tools/test_column_parameters.py @@ -1,12 +1,11 @@ """ Tests for tool parameters, more tests exist in test_data_parameters.py and test_select_parameters.py. """ - from galaxy import model from galaxy.util import bunch -from tools_support import datatypes_registry from .test_parameter_parsing import BaseParameterTestCase +from ..tools_support import datatypes_registry class DataColumnParameterTestCase(BaseParameterTestCase): diff --git a/test/unit/tools/test_data_parameters.py b/test/unit/tools/test_data_parameters.py index 561dff9e205..9fd0f521042 100644 --- a/test/unit/tools/test_data_parameters.py +++ b/test/unit/tools/test_data_parameters.py @@ -1,14 +1,8 @@ -import os -import sys - from galaxy import model from galaxy.util import bunch -unit_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) -sys.path.insert(1, unit_root) -from unittest_utils import galaxy_mock - from .test_parameter_parsing import BaseParameterTestCase +from ..unittest_utils import galaxy_mock class DataToolParameterTestCase(BaseParameterTestCase): diff --git a/test/unit/tools/test_dataset_matcher.py b/test/unit/tools/test_dataset_matcher.py index 98c2a7d30bd..fe5b231eeb5 100644 --- a/test/unit/tools/test_dataset_matcher.py +++ b/test/unit/tools/test_dataset_matcher.py @@ -1,7 +1,6 @@ from unittest import TestCase from xml.etree.ElementTree import XML -import tools_support from galaxy import model from galaxy.tools.parameters import ( basic, @@ -10,9 +9,10 @@ from galaxy.tools.parameters import ( from galaxy.util import bunch from .test_data_parameters import MockHistoryDatasetAssociation +from ..tools_support import UsesApp -class DatasetMatcherTestCase(TestCase, tools_support.UsesApp): +class DatasetMatcherTestCase(TestCase, UsesApp): def test_hda_accessible(self): # Cannot access errored or discard datasets. diff --git a/test/unit/tools/test_evaluation.py b/test/unit/tools/test_evaluation.py index be7c9db772e..d0e38fc561c 100644 --- a/test/unit/tools/test_evaluation.py +++ b/test/unit/tools/test_evaluation.py @@ -27,8 +27,9 @@ from galaxy.tools.parameters.grouping import ( ) from galaxy.tools.parser.output_objects import ToolOutput from galaxy.util.bunch import Bunch + # Test fixtures for Galaxy infrastructure. -from tools_support import UsesApp +from ..tools_support import UsesApp # To Test: # - param_file handling. diff --git a/test/unit/tools/test_execution.py b/test/unit/tools/test_execution.py index f28606ff989..3182a271995 100644 --- a/test/unit/tools/test_execution.py +++ b/test/unit/tools/test_execution.py @@ -5,11 +5,12 @@ from unittest import TestCase from paste import httpexceptions import galaxy.model -import tools_support from galaxy.tools.parameters import params_to_incoming from galaxy.util.bunch import Bunch from galaxy.util.odict import odict +from .. import tools_support + BASE_REPEAT_TOOL_CONTENTS = ''' echo "$param1" #for $r in $repeat# "$r.param2" #end for# < $out1 diff --git a/test/unit/tools/test_history_imp_exp.py b/test/unit/tools/test_history_imp_exp.py index 599cad1d37e..02a6f967e3f 100644 --- a/test/unit/tools/test_history_imp_exp.py +++ b/test/unit/tools/test_history_imp_exp.py @@ -1,5 +1,4 @@ import os -import sys import tarfile from shutil import rmtree from tempfile import mkdtemp @@ -8,9 +7,7 @@ from galaxy import model from galaxy.exceptions import MalformedContents from galaxy.tools.imp_exp import JobImportHistoryArchiveWrapper, unpack_tar_gz_archive -unit_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) -sys.path.insert(1, unit_root) -from unittest_utils.galaxy_mock import MockApp +from ..unittest_utils.galaxy_mock import MockApp # good enough for the very specific tests we're writing as of now... diff --git a/test/unit/tools/test_parameter_parsing.py b/test/unit/tools/test_parameter_parsing.py index 32da6acb482..e6b3939b0b1 100644 --- a/test/unit/tools/test_parameter_parsing.py +++ b/test/unit/tools/test_parameter_parsing.py @@ -1,13 +1,14 @@ from unittest import TestCase from xml.etree.ElementTree import XML -import tools_support from galaxy import model from galaxy.tools.parameters import basic from galaxy.util import bunch +from ..tools_support import UsesApp -class BaseParameterTestCase(TestCase, tools_support.UsesApp): + +class BaseParameterTestCase(TestCase, UsesApp): def setUp(self): self.setup_app() diff --git a/test/unit/tools/test_toolbox.py b/test/unit/tools/test_toolbox.py index cf941b22e1b..d9366a8dab6 100644 --- a/test/unit/tools/test_toolbox.py +++ b/test/unit/tools/test_toolbox.py @@ -7,7 +7,6 @@ import unittest import routes from six import string_types -import tools_support from galaxy import model from galaxy.model import tool_shed_install from galaxy.model.tool_shed_install import mapping @@ -15,11 +14,12 @@ from galaxy.tools import ToolBox from galaxy.tools.cache import ToolCache from galaxy.webapps.galaxy.config_watchers import ConfigWatchers -from .test_toolbox_filters import mock_trans from .test_tool_loader import ( SIMPLE_MACRO, SIMPLE_TOOL_WITH_MACRO ) +from .test_toolbox_filters import mock_trans +from ..tools_support import UsesApp, UsesTools CONFIG_TEST_TOOL_VERSION_TEMPLATE = string.Template( @@ -37,7 +37,7 @@ CONFIG_TEST_TOOL_VERSION_1 = CONFIG_TEST_TOOL_VERSION_TEMPLATE.safe_substitute(d CONFIG_TEST_TOOL_VERSION_2 = CONFIG_TEST_TOOL_VERSION_TEMPLATE.safe_substitute(dict(version="2")) -class BaseToolBoxTestCase(unittest.TestCase, tools_support.UsesApp, tools_support.UsesTools): +class BaseToolBoxTestCase(unittest.TestCase, UsesApp, UsesTools): @property def integerated_tool_panel_path(self): diff --git a/test/unit/tools/test_toolbox_filters.py b/test/unit/tools/test_toolbox_filters.py index e334faa7c1e..b1fcf1da3bb 100644 --- a/test/unit/tools/test_toolbox_filters.py +++ b/test/unit/tools/test_toolbox_filters.py @@ -1,5 +1,4 @@ from galaxy.tools.toolbox.filters import FilterFactory - from galaxy.util.bunch import Bunch @@ -50,7 +49,7 @@ def filter_factory(config_dict=None): tool_label_filters=["filtermod:filter_label_1", "filtermod:filter_label_2"], ) config = Bunch(**config_dict) - config.toolbox_filter_base_modules = "galaxy.tools.filters,tools.filter_modules" + config.toolbox_filter_base_modules = "galaxy.tools.filters,unit.tools.filter_modules" app = Bunch(config=config) toolbox = Bunch(app=app) return FilterFactory(toolbox) diff --git a/test/unit/visualizations/plugins/test_VisualizationPlugin.py b/test/unit/visualizations/plugins/test_VisualizationPlugin.py index 96460fabe21..eae02765c60 100644 --- a/test/unit/visualizations/plugins/test_VisualizationPlugin.py +++ b/test/unit/visualizations/plugins/test_VisualizationPlugin.py @@ -1,8 +1,6 @@ """ Test lib/galaxy/visualization/plugins/plugin. """ -import os -import sys import unittest from six import string_types @@ -13,12 +11,9 @@ from galaxy.visualization.plugins import ( utils as vis_utils ) -unit_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) -sys.path.insert(1, unit_root) -from unittest_utils import galaxy_mock, utility +from ...unittest_utils import galaxy_mock, utility -# ----------------------------------------------------------------------------- class VisualizationsPlugin_TestCase(unittest.TestCase): plugin_class = vis_plugin.VisualizationPlugin diff --git a/test/unit/visualizations/plugins/test_VisualizationsRegistry.py b/test/unit/visualizations/plugins/test_VisualizationsRegistry.py index dc00310ced2..7ed3b8af10a 100644 --- a/test/unit/visualizations/plugins/test_VisualizationsRegistry.py +++ b/test/unit/visualizations/plugins/test_VisualizationsRegistry.py @@ -3,7 +3,6 @@ Test lib/galaxy/visualization/plugins/registry. """ import os import re -import sys import unittest from six import string_types @@ -12,11 +11,8 @@ from galaxy import model from galaxy.visualization.plugins import plugin from galaxy.visualization.plugins.registry import VisualizationsRegistry -unit_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) -sys.path.insert(1, unit_root) -from unittest_utils import galaxy_mock, utility +from ...unittest_utils import galaxy_mock, utility -# ----------------------------------------------------------------------------- glx_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir)) template_cache_dir = os.path.join(glx_dir, 'database', 'compiled_templates') addtional_templates_dir = os.path.join(glx_dir, 'config', 'plugins', 'visualizations', 'common', 'templates') @@ -41,7 +37,6 @@ config1 = """\ """ -# ----------------------------------------------------------------------------- class VisualizationsRegistry_TestCase(unittest.TestCase): def test_plugin_load_from_repo(self): diff --git a/test/unit/web/framework/test_webapp.py b/test/unit/web/framework/test_webapp.py index d6efd9bfb45..319b980498c 100644 --- a/test/unit/web/framework/test_webapp.py +++ b/test/unit/web/framework/test_webapp.py @@ -2,17 +2,13 @@ Unit tests for ``galaxy.web.framework.webapp`` """ import logging -import os import re -import sys import unittest import galaxy.config from galaxy.web.framework import webapp as Webapp -unit_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) -sys.path.insert(1, unit_root) -from unittest_utils import galaxy_mock +from ...unittest_utils import galaxy_mock log = logging.getLogger(__name__)