Skip to content

Commit

Permalink
Merge pull request #3177 from nsoranzo/flake8-import-order
Browse files Browse the repository at this point in the history
Fix import order and Python3 compatibility for test/unit/
  • Loading branch information
jmchilton committed Nov 16, 2016
2 parents a86a457 + a8746c4 commit 2f2d21a
Show file tree
Hide file tree
Showing 54 changed files with 322 additions and 338 deletions.
44 changes: 28 additions & 16 deletions .ci/flake8_lint_include_list.txt
Expand Up @@ -516,52 +516,64 @@ 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/__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/__init__.py
test/unit/jobs/dynamic_tool_destination/mockGalaxy.py
test/unit/jobs/dynamic_tool_destination/ymltests.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_HistoryManager.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_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_data_parameters.py
test/unit/tools/test_tool_dependency_description.py
test/unit/tools/test_tool_panel.py
test/unit/tools/test_actions.py
test/unit/tools/test_citations.py
test/unit/tools/test_collect_primary_datasets.py
test/unit/tools/test_conda_resolution.py
test/unit/tools/test_dataset_matcher.py
test/unit/tools/test_parameter_parsing.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_toolbox_filters.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/__init__.py
test/unit/unittest_utils/utility.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/__init__.py
test/unit/workflows/test_extract_summary.py
test/unit/workflows/test_modules.py
test/unit/workflows/test_render.py
test/unit/workflows/test_workflow_progress.py
test/unit/workflows/
test/unit/test_objectstore.py
tool_list.py
tools/
5 changes: 3 additions & 2 deletions test/manual/workflows_scaling.py
Expand Up @@ -20,7 +20,8 @@
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 api import helpers, yaml_to_workflow
from api import helpers
from api.workflows_format_2.converter import python_to_workflow

LONG_TIMEOUT = 1000000000
DESCRIPTION = "Script to exercise the workflow engine."
Expand Down Expand Up @@ -53,7 +54,7 @@ def main(argv=None):

gi = _gi(args)

workflow = yaml_to_workflow.python_to_workflow(workflow_struct)
workflow = python_to_workflow(workflow_struct)
workflow_info = gi.workflows.import_workflow_json(workflow)
workflow_id = workflow_info["id"]

Expand Down
6 changes: 3 additions & 3 deletions test/unit/dataset_collections/test_matching.py
@@ -1,7 +1,7 @@
from galaxy.dataset_collections import (
type_description,
registry,
matching,
registry,
type_description,
)

TYPE_REGISTRY = registry.DatasetCollectionTypesRegistry( None )
Expand Down Expand Up @@ -98,7 +98,7 @@ def list_instance( collection_type="list", elements=None, ids=None ):
if not elements:
if ids is None:
ids = [ "data1", "data2" ]
elements = map(hda_element, ids)
elements = [hda_element(_) for _ in ids]
list_collection_instance = collection_instance(
collection_type=collection_type,
elements=elements
Expand Down
26 changes: 13 additions & 13 deletions test/unit/datatypes/dataproviders/test_base_dataproviders.py
Expand Up @@ -2,20 +2,20 @@
Unit tests for base DataProviders.
.. seealso:: galaxy.datatypes.dataproviders.base
"""

import logging
import os.path
import imp
import sys
import unittest

from six import StringIO

import logging
log = logging.getLogger( __name__ )
from galaxy.datatypes.dataproviders import base, exceptions

test_utils = imp.load_source( 'test_utils',
os.path.join( os.path.dirname( __file__), '../../unittest_utils/utility.py' ) )
import tempfilecache
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 galaxy.datatypes.dataproviders import base, exceptions
log = logging.getLogger( __name__ )

# TODO: fix imports there after dist and retry
# TODO: fix off by ones in FilteredDataProvider counters
Expand Down Expand Up @@ -52,7 +52,7 @@ def tearDown( self ):

def format_tmpfile_contents( self, contents=None ):
contents = contents or self.default_file_contents
contents = test_utils.clean_multiline_string( contents )
contents = utility.clean_multiline_string( contents )
log.debug( 'file contents:\n%s', contents )
return contents

Expand Down Expand Up @@ -135,7 +135,7 @@ def test_readlines( self ):
def test_stringio( self ):
"""should work with StringIO
"""
contents = test_utils.clean_multiline_string( """
contents = utility.clean_multiline_string( """
One
Two
Three
Expand Down Expand Up @@ -297,7 +297,7 @@ class Test_MultiSourceDataProvider( BaseTestCase ):
def contents_and_tmpfile( self, contents=None ):
# TODO: hmmmm...
contents = contents or self.default_file_contents
contents = test_utils.clean_multiline_string( contents )
contents = utility.clean_multiline_string( contents )
return ( contents, self.tmpfiles.create_tmpfile( contents ) )

def test_multiple_sources( self ):
Expand All @@ -323,7 +323,7 @@ def test_multiple_sources( self ):
Twelve! (<-- http://youtu.be/JZshZp-cxKg)
"""
]
contents = [ test_utils.clean_multiline_string( c ) for c in contents ]
contents = [ utility.clean_multiline_string( c ) for c in contents ]
source_list = [ open( self.tmpfiles.create_tmpfile( c ) ) for c in contents ]

provider = self.provider_class( source_list )
Expand Down Expand Up @@ -355,7 +355,7 @@ def test_multiple_compound_sources( self ):
Twelve! (<-- http://youtu.be/JZshZp-cxKg)
"""
]
contents = [ test_utils.clean_multiline_string( c ) for c in contents ]
contents = [ utility.clean_multiline_string( c ) for c in contents ]
source_list = [ open( self.tmpfiles.create_tmpfile( c ) ) for c in contents ]

def no_Fs( string ):
Expand Down
12 changes: 4 additions & 8 deletions test/unit/datatypes/dataproviders/test_line_dataproviders.py
Expand Up @@ -2,18 +2,14 @@
Unit tests for base DataProviders.
.. seealso:: galaxy.datatypes.dataproviders.base
"""

import imp
import unittest
import os.path
import logging
log = logging.getLogger( __name__ )
import unittest

test_utils = imp.load_source( 'test_utils',
os.path.join( os.path.dirname( __file__), '../../unittest_utils/utility.py' ) )
from galaxy.datatypes.dataproviders import line

from . import test_base_dataproviders
from galaxy.datatypes.dataproviders import line

log = logging.getLogger( __name__ )


# TODO: TestCase hierarchy is a bit of mess here.
Expand Down
@@ -1,16 +1,15 @@
import logging
import os
import sys
sys.path.append("")
import unittest
import mockGalaxy as mg
import ymltests as yt
import galaxy.jobs.dynamic_tool_destination as dt

from galaxy.jobs.dynamic_tool_destination import map_tool_to_destination
from testfixtures import log_capture

import galaxy.jobs.dynamic_tool_destination as dt
from galaxy.jobs.dynamic_tool_destination import map_tool_to_destination
from galaxy.jobs.mapper import JobMappingException

from . import mockGalaxy as mg
from . import ymltests as yt

theApp = mg.App( "waffles_default", "test_spec")
script_dir = os.path.dirname(__file__)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/jobs/test_command_factory.py
@@ -1,6 +1,6 @@
import os
from os import getcwd
import shutil
from os import getcwd
from tempfile import mkdtemp
from unittest import TestCase

Expand Down
2 changes: 1 addition & 1 deletion test/unit/jobs/test_job_configuration.py
Expand Up @@ -4,8 +4,8 @@
import tempfile
import unittest

from galaxy.util import bunch
from galaxy.jobs import JobConfiguration
from galaxy.util import bunch

# File would be slightly more readable if contents were embedded directly, but
# there are advantages to testing the documentation/examples.
Expand Down
7 changes: 4 additions & 3 deletions test/unit/jobs/test_job_output_checker.py
@@ -1,9 +1,10 @@
from unittest import TestCase
from galaxy.util.bunch import Bunch
from galaxy.jobs.output_checker import check_output

from galaxy.jobs.error_level import StdioErrorLevel
from galaxy.tools.parser.interface import ToolStdioRegex
from galaxy.jobs.output_checker import check_output
from galaxy.model import Job
from galaxy.tools.parser.interface import ToolStdioRegex
from galaxy.util.bunch import Bunch


class OutputCheckerTestCase( TestCase ):
Expand Down
17 changes: 10 additions & 7 deletions test/unit/jobs/test_job_wrapper.py
@@ -1,15 +1,18 @@
import os
from contextlib import contextmanager

from unittest import TestCase
from galaxy.model import Job
from galaxy.model import Task
from galaxy.model import User
from galaxy.jobs import JobWrapper
from galaxy.jobs import TaskWrapper
from galaxy.util.bunch import Bunch

from galaxy.jobs import (
JobWrapper,
TaskWrapper
)
from galaxy.model import (
Job,
Task,
User
)
from galaxy.tools import evaluation
from galaxy.util.bunch import Bunch

from tools_support import UsesApp

Expand Down
11 changes: 5 additions & 6 deletions test/unit/jobs/test_mapper.py
@@ -1,16 +1,15 @@
import uuid

import jobs.test_rules

from galaxy.jobs import JobDestination
from galaxy.jobs.mapper import (
JobRunnerMapper,
ERROR_MESSAGE_NO_RULE_FUNCTION,
ERROR_MESSAGE_RULE_FUNCTION_NOT_FOUND,
JobRunnerMapper,
)
from galaxy.jobs import JobDestination

from galaxy.util import bunch

from . import test_rules

WORKFLOW_UUID = uuid.uuid1().hex
TOOL_JOB_DESTINATION = JobDestination()
DYNAMICALLY_GENERATED_DESTINATION = JobDestination()
Expand Down Expand Up @@ -107,7 +106,7 @@ def __mapper( tool_job_destination=TOOL_JOB_DESTINATION ):
{},
job_config
)
mapper.rules_module = jobs.test_rules
mapper.rules_module = test_rules
return mapper


Expand Down
5 changes: 2 additions & 3 deletions test/unit/jobs/test_rule_helper.py
@@ -1,10 +1,9 @@
import uuid

from galaxy.util import bunch
from galaxy import model
from galaxy.model import mapping

from galaxy.jobs.rule_helper import RuleHelper
from galaxy.model import mapping
from galaxy.util import bunch

USER_EMAIL_1 = "u1@example.com"
USER_EMAIL_2 = "u2@example.com"
Expand Down
6 changes: 3 additions & 3 deletions test/unit/jobs/test_runner_local.py
Expand Up @@ -3,10 +3,10 @@
import time
from unittest import TestCase

from galaxy.util import bunch
from galaxy.jobs.runners import local
from galaxy.jobs import metrics
from galaxy import model
from galaxy.jobs import metrics
from galaxy.jobs.runners import local
from galaxy.util import bunch

from tools_support import (
UsesApp,
Expand Down

0 comments on commit 2f2d21a

Please sign in to comment.