summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-05-01 13:15:51 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-05-01 13:15:51 -0400
commit2ef1c56436d25e8a710a8679c59400c0e4009cd6 (patch)
tree0a68433ec8225880afb4802d19579e6c6ef9324a
parent95949db715ff54be01bfd260a51903ede60597ae (diff)
downloadsqlalchemy-2ef1c56436d25e8a710a8679c59400c0e4009cd6.tar.gz
- 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
-rw-r--r--lib/sqlalchemy/testing/config.py7
-rw-r--r--lib/sqlalchemy/testing/exclusions.py3
-rw-r--r--lib/sqlalchemy/testing/plugin/noseplugin.py3
-rw-r--r--lib/sqlalchemy/testing/plugin/plugin_base.py25
-rw-r--r--lib/sqlalchemy/testing/plugin/pytestplugin.py5
-rw-r--r--lib/sqlalchemy/testing/profiling.py10
6 files changed, 36 insertions, 17 deletions
diff --git a/lib/sqlalchemy/testing/config.py b/lib/sqlalchemy/testing/config.py
index d429c9f4e..a3d6e1690 100644
--- a/lib/sqlalchemy/testing/config.py
+++ b/lib/sqlalchemy/testing/config.py
@@ -15,6 +15,7 @@ file_config = None
test_schema = None
test_schema_2 = None
_current = None
+_skip_test_exception = None
class Config(object):
@@ -83,3 +84,9 @@ class Config(object):
for cfg in cls.all_configs():
yield cfg.db
+ def skip_test(self, msg):
+ skip_test(msg)
+
+
+def skip_test(msg):
+ raise _skip_test_exception(msg)
diff --git a/lib/sqlalchemy/testing/exclusions.py b/lib/sqlalchemy/testing/exclusions.py
index 6aa4bf142..972dec3a9 100644
--- a/lib/sqlalchemy/testing/exclusions.py
+++ b/lib/sqlalchemy/testing/exclusions.py
@@ -7,7 +7,6 @@
import operator
-from .plugin.plugin_base import SkipTest
from ..util import decorator
from . import config
from .. import util
@@ -116,7 +115,7 @@ class compound(object):
fn.__name__,
skip._as_string(config)
)
- raise SkipTest(msg)
+ config.skip_test(msg)
try:
return_value = fn(*args, **kw)
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."""
@@ -235,6 +235,13 @@ def _monkeypatch_cdecimal(options, file_config):
@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
from sqlalchemy import testing
@@ -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
diff --git a/lib/sqlalchemy/testing/profiling.py b/lib/sqlalchemy/testing/profiling.py
index 65fe165cd..357735656 100644
--- a/lib/sqlalchemy/testing/profiling.py
+++ b/lib/sqlalchemy/testing/profiling.py
@@ -16,7 +16,6 @@ import os
import sys
from .util import gc_collect
from . import config
-from .plugin.plugin_base import SkipTest
import pstats
import collections
import contextlib
@@ -205,10 +204,11 @@ def count_functions(variance=0.05):
raise SkipTest("cProfile is not installed")
if not _profile_stats.has_stats() and not _profile_stats.write:
- raise SkipTest("No profiling stats available on this "
- "platform for this function. Run tests with "
- "--write-profiles to add statistics to %s for "
- "this platform." % _profile_stats.short_fname)
+ config.skip_test(
+ "No profiling stats available on this "
+ "platform for this function. Run tests with "
+ "--write-profiles to add statistics to %s for "
+ "this platform." % _profile_stats.short_fname)
gc_collect()