Skip to content

Commit

Permalink
Drop nose
Browse files Browse the repository at this point in the history
It's deprecated and unmaintained, and is broken under Python 3.10 .
  • Loading branch information
nsoranzo committed May 11, 2022
1 parent c154561 commit 222e940
Show file tree
Hide file tree
Showing 27 changed files with 50 additions and 182 deletions.
13 changes: 8 additions & 5 deletions doc/source/dev/run_tests_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
'run_tests.sh -list' for listing all the tool ids
'run_tests.sh -api (test_path)' for running all the test scripts in the ./lib/galaxy_test/api directory, test_path
can be pytest selector
'run_tests.sh -cwl (test_path)' for running all the test scripts in the ./lib/galaxy_test/api/cwl directory, test_path
can be pytest selector
'run_tests.sh -integration (test_path)' for running all integration test scripts in the ./test/integration directory, test_path
can be pytest selector
'run_tests.sh -toolshed (test_path)' for running all the test scripts in the ./lib/tool_shed/test directory
Expand Down Expand Up @@ -51,7 +53,7 @@ as test_path. A few examples are shown below.
Run all API tests:
./run_tests.sh -api

The same test as above can be run using nosetests directly as follows:
The same test as above can be run using pytest directly as follows:
pytest lib/galaxy_test/api

However when using pytest directly output options defined in this
Expand Down Expand Up @@ -141,6 +143,10 @@ Extra options:
--verbose_errors Force some tests produce more verbose error reporting.
--no_cleanup Do not delete temp files for Python functional tests
(-toolshed, -framework, etc...)
--coverage Generate a test coverage report. This option currently
should work with every test that uses pytest, but the
results may not be reliable with selenium or other
frameworks that primarily test the client.
--debug On python test error or failure invoke a pdb shell for
interactive debugging of the test
--report_file Path of HTML report to produce (for Python Galaxy
Expand All @@ -150,10 +156,6 @@ Extra options:
functional tests).
--skip-venv Do not create .venv (passes this flag to
common_startup.sh)
--dockerize Run tests in a pre-configured Docker container (must be
first argument if present).
--db <type> For use with --dockerize, run tests using partially
migrated 'postgres', 'mysql', or 'sqlite' databases.
--external_url External URL to use for Galaxy testing (only certain
tests).
--external_master_key Master API key used to configure external tests.
Expand Down Expand Up @@ -238,6 +240,7 @@ TOOL_SHED_TEST_TMP_DIR Defaults to random /tmp directory - place for
tool shed test server files to be placed.
TOOL_SHED_TEST_OMIT_GALAXY Do not launch a Galaxy server for tool shed
testing.
GALAXY_TEST_DISABLE_ACCESS_LOG Do not log access messages

Unit Test Environment Variables

Expand Down
8 changes: 0 additions & 8 deletions doc/source/lib/galaxy_test.base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ galaxy\_test.base.interactor module
:undoc-members:
:show-inheritance:

galaxy\_test.base.nose\_util module
-----------------------------------

.. automodule:: galaxy_test.base.nose_util
:members:
:undoc-members:
:show-inheritance:

galaxy\_test.base.populators module
-----------------------------------

Expand Down
2 changes: 0 additions & 2 deletions lib/galaxy/dependencies/dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ msgpack==1.0.3; python_version >= "3.7" and python_version < "4"
mypy-extensions==0.4.3; python_version >= "3.7" and python_version < "4" and python_full_version >= "3.6.2"
networkx==2.5; python_version >= "3.6" and python_version < "4"
nodeenv==1.6.0
nose==1.3.7
nosehtml==0.4.6
numpy==1.21.6; python_version >= "3.7" and python_version < "3.11"
oauthlib==3.2.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
outcome==1.1.0; python_version >= "3.7" and python_version < "4.0"
Expand Down
1 change: 0 additions & 1 deletion lib/galaxy/dependencies/pinned-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ msgpack==1.0.3; python_version >= "3.7" and python_version < "4"
mypy-extensions==0.4.3; python_version >= "3.6" and python_version < "4"
networkx==2.5; python_version >= "3.6" and python_version < "4"
nodeenv==1.6.0
nose==1.3.7
numpy==1.21.6; python_version >= "3.7" and python_version < "3.11"
oauthlib==3.2.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
oyaml==1.0
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tool_util/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def found_warns(self) -> bool:
return len(self.warn_messages) > 0

def lint(self, name: str, lint_func: Callable[[LintTargetType, "LintContext"], None], lint_target: LintTargetType):
name = name.replace("tsts", "tests")[len("lint_") :]
name = name[len("lint_") :]
if name in self.skip_types:
return

Expand Down
3 changes: 1 addition & 2 deletions lib/galaxy/tool_util/linters/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from ..verify import asserts


# Misspelled so as not be picked up by nosetests.
def lint_tsts(tool_xml, lint_ctx):
def lint_tests(tool_xml, lint_ctx):
# determine node to report for general problems with tests
tests = tool_xml.findall("./tests/test")
general_node = tool_xml.find("./tests")
Expand Down
11 changes: 0 additions & 11 deletions lib/galaxy/tool_util/verify/interactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@
from packaging.version import Version
from requests.cookies import RequestsCookieJar

try:
from nose.tools import nottest
except ImportError:

def nottest(x):
return x


from galaxy import util
from galaxy.tool_util.parser.interface import (
TestCollectionDef,
Expand Down Expand Up @@ -351,13 +343,11 @@ def publish_history(self, history_id):
response = self._put(f"histories/{history_id}", json.dumps({"published": True}))
response.raise_for_status()

@nottest
def test_data_path(self, tool_id, filename, tool_version=None):
version_fragment = f"&tool_version={tool_version}" if tool_version else ""
response = self._get(f"tools/{tool_id}/test_data_path?filename={filename}{version_fragment}", admin=True)
return response.json()

@nottest
def test_data_download(self, tool_id, filename, mode="file", is_output=True, tool_version=None):
result = None
local_path = None
Expand Down Expand Up @@ -1543,7 +1533,6 @@ def to_dict(self):
}


@nottest
def test_data_iter(required_files):
for fname, extra in required_files:
data_dict = dict(
Expand Down
9 changes: 0 additions & 9 deletions lib/galaxy/tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,9 @@
unicodify,
)

try:
from nose.tools import nottest
except ImportError:

def nottest(x):
return x


log = logging.getLogger(__name__)


@nottest
def parse_tests(tool, tests_source):
"""
Build ToolTestDescription objects for each "<test>" elements and
Expand Down
3 changes: 1 addition & 2 deletions lib/galaxy_test/api/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time
import urllib.parse
from operator import itemgetter
from unittest import SkipTest

import requests
from dateutil.parser import isoparse
Expand Down Expand Up @@ -496,8 +497,6 @@ def test_purging_output_cleaned_after_ok_run(self, history_id):
assert not os.path.exists(output_dataset_paths[0])

def _hack_to_skip_test_if_state_ok(self, job_state):
from nose.plugins.skip import SkipTest

if job_state().json()["state"] == "ok":
message = "Job state switch from running to ok too quickly - the rest of the test requires the job to be in a running state. Skipping test."
raise SkipTest(message)
Expand Down
26 changes: 0 additions & 26 deletions lib/galaxy_test/base/nose_util.py

This file was deleted.

8 changes: 3 additions & 5 deletions lib/galaxy_test/base/populators.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import random
import string
import time
import unittest
import urllib.parse
from abc import (
ABCMeta,
Expand All @@ -62,6 +61,7 @@
Set,
Tuple,
)
from unittest import SkipTest

import cwltest
import requests
Expand Down Expand Up @@ -109,11 +109,11 @@ def flakey(method):
def wrapped_method(test_case, *args, **kwargs):
try:
method(test_case, *args, **kwargs)
except unittest.SkipTest:
except SkipTest:
raise
except Exception:
if SKIP_FLAKEY_TESTS_ON_ERROR:
raise unittest.SkipTest("Error encountered during test marked as @flakey.")
raise SkipTest("Error encountered during test marked as @flakey.")
else:
raise

Expand Down Expand Up @@ -220,8 +220,6 @@ def wrapped_method(api_test_case, *args, **kwds):

def _raise_skip_if(check, *args):
if check:
from nose.plugins.skip import SkipTest

raise SkipTest(*args)


Expand Down
41 changes: 22 additions & 19 deletions lib/galaxy_test/driver/driver_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
target_url_parts,
)
from galaxy_test.base.instrument import StructuredTestDataPlugin
from galaxy_test.base.nose_util import run
from tool_shed.webapp.app import UniverseApplication as ToolshedUniverseApplication
from tool_shed.webapp.fast_app import initialize_fast_app as init_tool_shed_fast_app
from .test_logging import logging_config_file
Expand Down Expand Up @@ -80,6 +79,22 @@
install_context = None


def run(test_config):
loader = nose.loader.TestLoader(config=test_config)
plug_loader = test_config.plugins.prepareTestLoader(loader)
if plug_loader is not None:
loader = plug_loader
tests = loader.loadTestsFromNames(test_config.testNames)
test_runner = nose.core.TextTestRunner(
stream=test_config.stream, verbosity=test_config.verbosity, config=test_config
)
plug_runner = test_config.plugins.prepareTestRunner(test_runner)
if plug_runner is not None:
test_runner = plug_runner
result = test_runner.run(tests)
return result


def setup_tool_shed_tmp_dir():
tool_shed_test_tmp_dir = os.environ.get("TOOL_SHED_TEST_TMP_DIR", None)
if tool_shed_test_tmp_dir is None:
Expand Down Expand Up @@ -333,34 +348,23 @@ def _tool_data_table_config_path(default_tool_data_table_config_path=None):
return tool_data_table_config_path


def nose_config_and_run(argv=None, env=None, ignore_files=None, plugins=None):
def nose_config_and_run():
"""Setup a nose context and run tests.
Tests are specified by argv (defaulting to sys.argv).
Tests are specified by sys.argv .
"""
if env is None:
env = os.environ
if ignore_files is None:
ignore_files = []
if plugins is None:
plugins = nose.plugins.manager.DefaultPluginManager()
if argv is None:
argv = sys.argv

test_config = nose.config.Config(
env=os.environ,
ignoreFiles=ignore_files,
plugins=plugins,
ignoreFiles=[],
plugins=nose.plugins.manager.DefaultPluginManager(),
)

# Add custom plugin to produce JSON data used by planemo.
test_config.plugins.addPlugin(StructuredTestDataPlugin())
test_config.configure(argv)
test_config.configure(sys.argv)

result = run(test_config)

success = result.wasSuccessful()
return success
return result.wasSuccessful()


def copy_database_template(source, db_path):
Expand Down Expand Up @@ -1096,7 +1100,6 @@ def drive_test(test_driver_class):
"FRAMEWORK_DATATYPES_CONF",
"database_conf",
"get_webapp_global_conf",
"nose_config_and_run",
"setup_galaxy_config",
"TestDriver",
"wait_for_http_server",
Expand Down
10 changes: 1 addition & 9 deletions lib/galaxy_test/selenium/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@
window.localStorage && window.localStorage.setItem("galaxy:debug:flatten", true);
"""

try:
from nose.tools import nottest
except ImportError:

def nottest(x):
return x


def managed_history(f):
"""Ensure a Selenium test has a distinct, named history.
Expand Down Expand Up @@ -167,7 +160,6 @@ def write_file(name, content, raw=False):
continue


@nottest
def selenium_test(f):
test_name = f.__name__

Expand Down Expand Up @@ -238,7 +230,7 @@ def workflow_populator(self) -> populators.BaseWorkflowPopulator:


class TestWithSeleniumMixin(GalaxyTestSeleniumContext, UsesApiTestCaseMixin):
# If run one-off via nosetests, the next line ensures test
# If run one-off via pytest, the next line ensures test
# tools and datatypes are used instead of configured tools.
framework_tool_and_types = True

Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ MarkupSafe = "*"
Mercurial = "*"
mrcfile = "*"
nodeenv = "*"
nose = "*"
numpy = "*"
paramiko = "!=2.9.0, !=2.9.1" # https://github.com/paramiko/paramiko/issues/1961
Parsley = "*"
Expand Down Expand Up @@ -119,7 +118,6 @@ httpx = "*"
isort = "^5.10.1"
lxml = "!=4.2.2"
markdown-it-reporter = "*"
NoseHTML = "*"
PyGithub = "*"
pytest = "*"
pytest-asyncio = "*"
Expand Down
9 changes: 4 additions & 5 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ exists() {
type "$1" >/dev/null 2>/dev/null
}

debug=""
test_script="./scripts/functional_tests.py"
report_file="run_functional_tests.html"
coverage_arg=""
Expand Down Expand Up @@ -495,9 +496,7 @@ do
shift
;;
--debug)
#TODO ipdb would be nicer.
NOSE_PDB=True
export NOSE_PDB
debug="--pdb"
shift
;;
-u|-unit|--unit)
Expand Down Expand Up @@ -651,10 +650,10 @@ if [ "$test_script" = 'pytest' ]; then
else
marker_args=()
fi
args=(-v $structured_data_args --html "$report_file" --self-contained-html $coverage_arg $xunit_args $extra_args "${marker_args[@]}" "$@")
args=(-v $debug $structured_data_args --html "$report_file" --self-contained-html $coverage_arg $xunit_args $extra_args "${marker_args[@]}" "$@")
"$test_script" "${args[@]}"
else
python "$test_script" $coverage_arg -v --with-nosehtml --html-report-file $report_file $xunit_args $structured_data_args $extra_args "$@"
python "$test_script" $coverage_arg -v --html-report-file $report_file $xunit_args $structured_data_args $extra_args "$@"
fi
exit_status=$?
echo "Testing complete. HTML report is in \"$report_file\"." 1>&2
Expand Down
Loading

0 comments on commit 222e940

Please sign in to comment.