From 50866d2f857dd45bb2d186a0fa076768437d62a3 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 10 Mar 2015 15:24:28 -0400 Subject: - copyright 2015 --- lib/sqlalchemy/testing/plugin/noseplugin.py | 2 +- lib/sqlalchemy/testing/plugin/plugin_base.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/testing/plugin') diff --git a/lib/sqlalchemy/testing/plugin/noseplugin.py b/lib/sqlalchemy/testing/plugin/noseplugin.py index 538087770..1ae6e28f5 100644 --- a/lib/sqlalchemy/testing/plugin/noseplugin.py +++ b/lib/sqlalchemy/testing/plugin/noseplugin.py @@ -1,5 +1,5 @@ # plugin/noseplugin.py -# Copyright (C) 2005-2014 the SQLAlchemy authors and contributors +# Copyright (C) 2005-2015 the SQLAlchemy authors and contributors # # # This module is part of SQLAlchemy and is released under diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index b0188aa5a..14cf1eb31 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -1,5 +1,5 @@ # plugin/plugin_base.py -# Copyright (C) 2005-2014 the SQLAlchemy authors and contributors +# Copyright (C) 2005-2015 the SQLAlchemy authors and contributors # # # This module is part of SQLAlchemy and is released under -- cgit v1.2.1 From 088666e8f3de4816b6eeadc2dce0f473b7710bff Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 1 May 2015 09:38:21 -0400 Subject: - Fixed an import that prevented "pypy setup.py test" from working correctly. fixes #3406 --- lib/sqlalchemy/testing/plugin/plugin_base.py | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/sqlalchemy/testing/plugin') diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index 14cf1eb31..84b7a6d5e 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -19,6 +19,7 @@ try: # honor it unless nose is imported too... from nose import SkipTest except ImportError: + import pytest from _pytest.runner import Skipped as SkipTest import sys -- cgit v1.2.1 From 2ef1c56436d25e8a710a8679c59400c0e4009cd6 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 1 May 2015 13:15:51 -0400 Subject: - move away from explicit raises of SkipTest, instead call a function patched onto config. nose/pytest backends now fill in their exception class here only when loaded - use more public seeming api to get at py.test Skipped exception --- lib/sqlalchemy/testing/plugin/noseplugin.py | 3 +++ lib/sqlalchemy/testing/plugin/plugin_base.py | 25 ++++++++++++++++--------- lib/sqlalchemy/testing/plugin/pytestplugin.py | 5 ++++- 3 files changed, 23 insertions(+), 10 deletions(-) (limited to 'lib/sqlalchemy/testing/plugin') diff --git a/lib/sqlalchemy/testing/plugin/noseplugin.py b/lib/sqlalchemy/testing/plugin/noseplugin.py index 1ae6e28f5..4c390d409 100644 --- a/lib/sqlalchemy/testing/plugin/noseplugin.py +++ b/lib/sqlalchemy/testing/plugin/noseplugin.py @@ -24,6 +24,7 @@ import os import sys from nose.plugins import Plugin +import nose fixtures = None py3k = sys.version_info >= (3, 0) @@ -56,6 +57,8 @@ class NoseSQLAlchemy(Plugin): 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 diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index 84b7a6d5e..ef304afa6 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -14,13 +14,6 @@ functionality via py.test. """ from __future__ import absolute_import -try: - # unitttest has a SkipTest also but pytest doesn't - # honor it unless nose is imported too... - from nose import SkipTest -except ImportError: - import pytest - from _pytest.runner import Skipped as SkipTest import sys import re @@ -157,6 +150,13 @@ def pre_begin(opt): def set_coverage_flag(value): options.has_coverage = value +_skip_test_exception = None + + +def set_skip_test(exc): + global _skip_test_exception + _skip_test_exception = exc + def post_begin(): """things to set up later, once we know coverage is running.""" @@ -234,6 +234,13 @@ def _monkeypatch_cdecimal(options, file_config): sys.modules['decimal'] = cdecimal +@post +def _init_skiptest(options, file_config): + from sqlalchemy.testing import config + + config._skip_test_exception = _skip_test_exception + + @post def _engine_uri(options, file_config): from sqlalchemy.testing import config @@ -507,7 +514,7 @@ def _do_skips(cls): if getattr(cls, '__skip_if__', False): for c in getattr(cls, '__skip_if__'): if c(): - raise SkipTest("'%s' skipped by %s" % ( + config.skip_test("'%s' skipped by %s" % ( cls.__name__, c.__name__) ) @@ -530,7 +537,7 @@ def _do_skips(cls): ), ", ".join(reasons) ) - raise SkipTest(msg) + config.skip_test(msg) elif hasattr(cls, '__prefer_backends__'): non_preferred = set() spec = exclusions.db_spec(*util.to_list(cls.__prefer_backends__)) diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py index fbab4966c..30d7aa73a 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -12,7 +12,7 @@ import collections import itertools try: - import xdist + import xdist # noqa has_xdist = True except ImportError: has_xdist = False @@ -48,6 +48,8 @@ def pytest_configure(config): plugin_base.set_coverage_flag(bool(getattr(config.option, "cov_source", False))) + plugin_base.set_skip_test(pytest.skip.Exception) + def pytest_sessionstart(session): plugin_base.post_begin() @@ -127,6 +129,7 @@ def pytest_pycollect_makeitem(collector, name, obj): _current_class = None + def pytest_runtest_setup(item): # here we seem to get called only based on what we collected # in pytest_collection_modifyitems. So to do class-based stuff -- cgit v1.2.1 From c8f38dff1143585226cd79865a6144d16ee0ba18 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 17 Jul 2015 11:09:29 -0400 Subject: - db_opts doesn't need to be a global since we no longer have any global option for it. keep it local to production of config so values don't leak in a multi --db situation. --- lib/sqlalchemy/testing/plugin/plugin_base.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lib/sqlalchemy/testing/plugin') diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index ef304afa6..6cdec05ad 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -40,7 +40,6 @@ file_config = None logging = None -db_opts = {} include_tags = set() exclude_tags = set() options = None @@ -115,7 +114,6 @@ def memoize_important_follower_config(dict_): """ dict_['memoized_config'] = { - 'db_opts': db_opts, 'include_tags': include_tags, 'exclude_tags': exclude_tags } @@ -127,8 +125,7 @@ def restore_important_follower_config(dict_): This invokes in the follower process. """ - global db_opts, include_tags, exclude_tags - db_opts.update(dict_['memoized_config']['db_opts']) + global include_tags, exclude_tags include_tags.update(dict_['memoized_config']['include_tags']) exclude_tags.update(dict_['memoized_config']['exclude_tags']) @@ -268,7 +265,7 @@ def _engine_uri(options, file_config): for db_url in db_urls: cfg = provision.setup_config( - db_url, db_opts, options, file_config, provision.FOLLOWER_IDENT) + db_url, options, file_config, provision.FOLLOWER_IDENT) if not config._current: cfg.set_as_current(cfg, testing) -- cgit v1.2.1 From 65010e97bca995657c2843f6aa8ad48bab370182 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 23 Jan 2016 14:58:42 -0500 Subject: - use uuid fragments for provision names to enable multiple test suites per server --- lib/sqlalchemy/testing/plugin/pytestplugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/testing/plugin') diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py index 30d7aa73a..5bb6b966d 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -55,7 +55,7 @@ def pytest_sessionstart(session): plugin_base.post_begin() if has_xdist: - _follower_count = itertools.count(1) + import uuid def pytest_configure_node(node): # the master for each node fills slaveinput dictionary @@ -63,7 +63,7 @@ if has_xdist: plugin_base.memoize_important_follower_config(node.slaveinput) - node.slaveinput["follower_ident"] = "test_%s" % next(_follower_count) + node.slaveinput["follower_ident"] = "test_%s" % uuid.uuid4().hex[0:12] from sqlalchemy.testing import provision provision.create_follower_db(node.slaveinput["follower_ident"]) -- cgit v1.2.1 From 859379e2fcc4506d036700ba1eca4c0ae526a8ee Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 29 Jan 2016 11:20:22 -0500 Subject: - happy new year --- lib/sqlalchemy/testing/plugin/noseplugin.py | 2 +- lib/sqlalchemy/testing/plugin/plugin_base.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/testing/plugin') diff --git a/lib/sqlalchemy/testing/plugin/noseplugin.py b/lib/sqlalchemy/testing/plugin/noseplugin.py index 4c390d409..9fc5848fb 100644 --- a/lib/sqlalchemy/testing/plugin/noseplugin.py +++ b/lib/sqlalchemy/testing/plugin/noseplugin.py @@ -1,5 +1,5 @@ # plugin/noseplugin.py -# Copyright (C) 2005-2015 the SQLAlchemy authors and contributors +# Copyright (C) 2005-2016 the SQLAlchemy authors and contributors # # # This module is part of SQLAlchemy and is released under diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index 6cdec05ad..84258df92 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -1,5 +1,5 @@ # plugin/plugin_base.py -# Copyright (C) 2005-2015 the SQLAlchemy authors and contributors +# Copyright (C) 2005-2016 the SQLAlchemy authors and contributors # # # This module is part of SQLAlchemy and is released under -- cgit v1.2.1 From 7cb2a2d6c0cb85f7c51fcd572136589c23aa7a1b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 8 Feb 2016 16:27:55 -0500 Subject: - additional fixes to get oracle + multiprocess to be reliable --- lib/sqlalchemy/testing/plugin/plugin_base.py | 7 +++++++ lib/sqlalchemy/testing/plugin/pytestplugin.py | 4 ++++ 2 files changed, 11 insertions(+) (limited to 'lib/sqlalchemy/testing/plugin') diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index 84258df92..22b79d1b3 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -174,6 +174,7 @@ def post_begin(): warnings.setup_filters() + def _log(opt_str, value, parser): global logging if not logging: @@ -436,6 +437,12 @@ def _restore_engine(): config._current.reset(testing) +def final_process_cleanup(): + engines.testing_reaper._stop_test_ctx_aggressive() + assertions.global_cleanup_assertions() + _restore_engine() + + def _setup_engine(cls): if getattr(cls, '__engine_options__', None): eng = engines.testing_engine(options=cls.__engine_options__) diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py index 5bb6b966d..0bd79eea0 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -54,6 +54,10 @@ def pytest_configure(config): def pytest_sessionstart(session): plugin_base.post_begin() + +def pytest_sessionfinish(session): + plugin_base.final_process_cleanup() + if has_xdist: import uuid -- cgit v1.2.1