summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-09-08 11:47:39 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-09-08 11:47:39 -0400
commitc63fe0d4495b0fc554a085a314e837d5404231d3 (patch)
tree9f36f8b3fdcbdd96e8acf937ce38c0ff7f739f06
parentecc98fd8e42632179f47c972dc1dac6e9170adcb (diff)
downloadsqlalchemy-pool_additions.tar.gz
- allow for the exclusions system and SuiteRequirements to bepool_additions
usable without the full plugin_base setup. - move some Python-env requirements to the importable requirements.py module. Change-Id: I3bfffce75b53040f6923b89e0fa2140bec243bc8
-rw-r--r--lib/sqlalchemy/testing/config.py7
-rw-r--r--lib/sqlalchemy/testing/exclusions.py16
-rw-r--r--lib/sqlalchemy/testing/plugin/plugin_base.py1
-rw-r--r--lib/sqlalchemy/testing/requirements.py40
-rw-r--r--test/requirements.py39
5 files changed, 56 insertions, 47 deletions
diff --git a/lib/sqlalchemy/testing/config.py b/lib/sqlalchemy/testing/config.py
index da5997661..6648f9130 100644
--- a/lib/sqlalchemy/testing/config.py
+++ b/lib/sqlalchemy/testing/config.py
@@ -15,7 +15,11 @@ file_config = None
test_schema = None
test_schema_2 = None
_current = None
-_skip_test_exception = None
+
+try:
+ from unittest import SkipTest as _skip_test_exception
+except ImportError:
+ _skip_test_exception = None
class Config(object):
@@ -90,3 +94,4 @@ class Config(object):
def skip_test(msg):
raise _skip_test_exception(msg)
+
diff --git a/lib/sqlalchemy/testing/exclusions.py b/lib/sqlalchemy/testing/exclusions.py
index b672656a0..fb1041db3 100644
--- a/lib/sqlalchemy/testing/exclusions.py
+++ b/lib/sqlalchemy/testing/exclusions.py
@@ -109,21 +109,21 @@ class compound(object):
else:
all_fails._expect_success(config._current)
- def _do(self, config, fn, *args, **kw):
+ def _do(self, cfg, fn, *args, **kw):
for skip in self.skips:
- if skip(config):
+ if skip(cfg):
msg = "'%s' : %s" % (
fn.__name__,
- skip._as_string(config)
+ skip._as_string(cfg)
)
config.skip_test(msg)
try:
return_value = fn(*args, **kw)
except Exception as ex:
- self._expect_failure(config, ex, name=fn.__name__)
+ self._expect_failure(cfg, ex, name=fn.__name__)
else:
- self._expect_success(config, name=fn.__name__)
+ self._expect_success(cfg, name=fn.__name__)
return return_value
def _expect_failure(self, config, ex, name='block'):
@@ -208,8 +208,10 @@ class Predicate(object):
if negate:
bool_ = not negate
return self.description % {
- "driver": config.db.url.get_driver_name(),
- "database": config.db.url.get_backend_name(),
+ "driver": config.db.url.get_driver_name()
+ if config else "<no driver>",
+ "database": config.db.url.get_backend_name()
+ if config else "<no database>",
"doesnt_support": "doesn't support" if bool_ else "does support",
"does_support": "does support" if bool_ else "doesn't support"
}
diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py
index fc9d71165..6581195df 100644
--- a/lib/sqlalchemy/testing/plugin/plugin_base.py
+++ b/lib/sqlalchemy/testing/plugin/plugin_base.py
@@ -267,6 +267,7 @@ def _engine_uri(options, file_config):
if not db_urls:
db_urls.append(file_config.get('db', 'default'))
+ config._current = None
for db_url in db_urls:
cfg = provision.setup_config(
db_url, options, file_config, provision.FOLLOWER_IDENT)
diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py
index a9370a30e..b0f466892 100644
--- a/lib/sqlalchemy/testing/requirements.py
+++ b/lib/sqlalchemy/testing/requirements.py
@@ -15,6 +15,8 @@ to provide specific inclusion/exclusions.
"""
+import sys
+
from . import exclusions
from .. import util
@@ -708,6 +710,44 @@ class SuiteRequirements(Requirements):
)
@property
+ def python2(self):
+ return exclusions.skip_if(
+ lambda: sys.version_info >= (3,),
+ "Python version 2.xx is required."
+ )
+
+ @property
+ def python3(self):
+ return exclusions.skip_if(
+ lambda: sys.version_info < (3,),
+ "Python version 3.xx is required."
+ )
+
+ @property
+ def cpython(self):
+ return exclusions.only_if(
+ lambda: util.cpython,
+ "cPython interpreter needed"
+ )
+
+ @property
+ def non_broken_pickle(self):
+ from sqlalchemy.util import pickle
+ return exclusions.only_if(
+ lambda: not util.pypy and pickle.__name__ == 'cPickle'
+ or sys.version_info >= (3, 2),
+ "Needs cPickle+cPython or newer Python 3 pickle"
+ )
+
+ @property
+ def predictable_gc(self):
+ """target platform must remove all cycles unconditionally when
+ gc.collect() is called, as well as clean out unreferenced subclasses.
+
+ """
+ return self.cpython
+
+ @property
def no_coverage(self):
"""Test should be skipped if coverage is enabled.
diff --git a/test/requirements.py b/test/requirements.py
index 9286a415d..c31f84c21 100644
--- a/test/requirements.py
+++ b/test/requirements.py
@@ -750,45 +750,6 @@ class DefaultRequirements(SuiteRequirements):
return fails_on("postgresql+pg8000")
@property
- def python2(self):
- return skip_if(
- lambda: sys.version_info >= (3,),
- "Python version 2.xx is required."
- )
-
- @property
- def python3(self):
- return skip_if(
- lambda: sys.version_info < (3,),
- "Python version 3.xx is required."
- )
-
- @property
- def cpython(self):
- return only_if(lambda: util.cpython,
- "cPython interpreter needed"
- )
-
-
- @property
- def non_broken_pickle(self):
- from sqlalchemy.util import pickle
- return only_if(
- lambda: not util.pypy and pickle.__name__ == 'cPickle'
- or sys.version_info >= (3, 2),
- "Needs cPickle+cPython or newer Python 3 pickle"
- )
-
-
- @property
- def predictable_gc(self):
- """target platform must remove all cycles unconditionally when
- gc.collect() is called, as well as clean out unreferenced subclasses.
-
- """
- return self.cpython
-
- @property
def hstore(self):
def check_hstore(config):
if not against(config, "postgresql"):