diff options
| author | Parth Shandilya <parth1989shandilya@gmail.com> | 2019-01-31 23:24:29 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-02-02 11:25:44 -0500 |
| commit | d427d0643b235ea0f6b50a357bbe5bdb087403c4 (patch) | |
| tree | 7761e13db68e0c49f27e2defcd9ea8965e1445c2 /lib/sqlalchemy/testing/plugin | |
| parent | 7e48d8b2a70b399ffa6ec874f824d6cee82980a0 (diff) | |
| download | sqlalchemy-d427d0643b235ea0f6b50a357bbe5bdb087403c4.tar.gz | |
Remove Nose support
The test system has removed support for Nose, which is unmaintained for
several years and is producing warnings under Python 3. The test suite is
currently standardized on Pytest. Pull request courtesy Parth Shandilya.
Fixes: #4460
Closes: #4476
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4476
Pull-request-sha: e857af9c7d07355e52841149ee2e5d4448409e1e
Change-Id: I76516fae1cf0eb58f2e9fc9f692e591e0fcf39a4
Diffstat (limited to 'lib/sqlalchemy/testing/plugin')
| -rw-r--r-- | lib/sqlalchemy/testing/plugin/bootstrap.py | 5 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/plugin/noseplugin.py | 113 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/plugin/plugin_base.py | 10 |
3 files changed, 6 insertions, 122 deletions
diff --git a/lib/sqlalchemy/testing/plugin/bootstrap.py b/lib/sqlalchemy/testing/plugin/bootstrap.py index 2230ae2a8..a95c947e2 100644 --- a/lib/sqlalchemy/testing/plugin/bootstrap.py +++ b/lib/sqlalchemy/testing/plugin/bootstrap.py @@ -1,5 +1,5 @@ """ -Bootstrapper for nose/pytest plugins. +Bootstrapper for test framework plugins. The entire rationale for this system is to get the modules in plugin/ imported without importing all of the supporting library, so that we can @@ -41,8 +41,5 @@ def load_file_as_module(name): if to_bootstrap == "pytest": sys.modules["sqla_plugin_base"] = load_file_as_module("plugin_base") sys.modules["sqla_pytestplugin"] = load_file_as_module("pytestplugin") -elif to_bootstrap == "nose": - sys.modules["sqla_plugin_base"] = load_file_as_module("plugin_base") - sys.modules["sqla_noseplugin"] = load_file_as_module("noseplugin") else: raise Exception("unknown bootstrap: %s" % to_bootstrap) # noqa diff --git a/lib/sqlalchemy/testing/plugin/noseplugin.py b/lib/sqlalchemy/testing/plugin/noseplugin.py deleted file mode 100644 index 05c62f791..000000000 --- a/lib/sqlalchemy/testing/plugin/noseplugin.py +++ /dev/null @@ -1,113 +0,0 @@ -# plugin/noseplugin.py -# Copyright (C) 2005-2019 the SQLAlchemy authors and contributors -# <see AUTHORS file> -# -# This module is part of SQLAlchemy and is released under -# the MIT License: http://www.opensource.org/licenses/mit-license.php - -"""Enhance nose with extra options and behaviors for running SQLAlchemy tests. - -Must be run via ./sqla_nose.py so that it is imported in the expected -way (e.g. as a package-less import). - -""" - -try: - # installed by bootstrap.py - import sqla_plugin_base as plugin_base -except ImportError: - # assume we're a package, use traditional import - from . import plugin_base - - -import os -import sys - -import nose -from nose.plugins import Plugin - - -fixtures = None - -py3k = sys.version_info >= (3, 0) - - -class NoseSQLAlchemy(Plugin): - enabled = True - - name = "sqla_testing" - score = 100 - - def options(self, parser, env=os.environ): - Plugin.options(self, parser, env) - opt = parser.add_option - - def make_option(name, **kw): - callback_ = kw.pop("callback", None) or kw.pop( - "zeroarg_callback", None - ) - if callback_: - - def wrap_(option, opt_str, value, parser): - callback_(opt_str, value, parser) - - kw["callback"] = wrap_ - opt(name, **kw) - - plugin_base.setup_options(make_option) - plugin_base.read_config() - - def configure(self, options, conf): - super(NoseSQLAlchemy, self).configure(options, conf) - plugin_base.pre_begin(options) - - plugin_base.set_coverage_flag(options.enable_plugin_coverage) - - plugin_base.set_skip_test(nose.SkipTest) - - def begin(self): - global fixtures - from sqlalchemy.testing import fixtures # noqa - - plugin_base.post_begin() - - def describeTest(self, test): - return "" - - def wantFunction(self, fn): - return False - - def wantMethod(self, fn): - if py3k: - if not hasattr(fn.__self__, "cls"): - return False - cls = fn.__self__.cls - else: - cls = fn.im_class - return plugin_base.want_method(cls, fn) - - def wantClass(self, cls): - return plugin_base.want_class(cls) - - def beforeTest(self, test): - if not hasattr(test.test, "cls"): - return - plugin_base.before_test( - test, - test.test.cls.__module__, - test.test.cls, - test.test.method.__name__, - ) - - def afterTest(self, test): - plugin_base.after_test(test) - - def startContext(self, ctx): - if not isinstance(ctx, type) or not issubclass(ctx, fixtures.TestBase): - return - plugin_base.start_test_class(ctx) - - def stopContext(self, ctx): - if not isinstance(ctx, type) or not issubclass(ctx, fixtures.TestBase): - return - plugin_base.stop_test_class(ctx) diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index 9c9e31142..ef44a5906 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -8,8 +8,9 @@ """Testing extensions. this module is designed to work as a testing-framework-agnostic library, -so that we can continue to support nose and also begin adding new -functionality via py.test. +created so that multiple test frameworks can be supported at once +(mostly so that we can migrate to new ones). The current target +is py.test. """ @@ -244,8 +245,7 @@ def post_begin(): for fn in post_configure: fn(options, file_config) - # late imports, has to happen after config as well - # as nose plugins like coverage + # late imports, has to happen after config. global util, fixtures, engines, exclusions, assertions global warnings, profiling, config, testing from sqlalchemy import testing # noqa @@ -575,7 +575,7 @@ def _setup_engine(cls): def before_test(test, test_module_name, test_class, test_name): - # like a nose id, e.g.: + # format looks like: # "test.aaa_profiling.test_compiler.CompileTest.test_update_whereclause" name = getattr(test_class, "_sa_orig_cls_name", test_class.__name__) |
