summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/exclusions.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-02-10 15:38:39 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-02-10 15:47:09 -0500
commit12ec0e06858d84097a051a50a60fe9a1582ee95c (patch)
tree3b634110dcdc004e7cd4b91b85dbc46396b04d32 /lib/sqlalchemy/testing/exclusions.py
parentee1d914888113ceb9928ece6e0a715c813bdfcfa (diff)
downloadsqlalchemy-12ec0e06858d84097a051a50a60fe9a1582ee95c.tar.gz
Rework combination exclusions
The technique arrived at for doing exclusions inside of combinations relies upon comparing all the arguments in a particular combination to some set of combinations that were gathered as having "exclusions". This logic is actually broken for the case where the @testing.combinations has an "id", but if we fix that, we still have the issue of all the arguments being compared, which is complicated and also doesn't work for the case of a py2/py3 incompatibility like a timezone that has fractional minutes or seconds in it. It's also not clear if a @testing.combinations that uses lambdas will work either (maybe it does though because lambdax == lambdax compares...). anyway, this patch reworks it so that we hit this on the decorator side instead, where we add our own decorator and go through the extra effort to create a decorator that accepts an extra argument of "exclusions" which we can then check in a way that is local to the whole pytest @combinations thing in the first place. The only difficulty is that pytest is very sneaky about looking at the test function so we need to make sure __wrapped__ isn't set when doing this. Change-Id: Ic57aae15b378e0f4ed009e4e82ae7ba73fb6dfc5
Diffstat (limited to 'lib/sqlalchemy/testing/exclusions.py')
-rw-r--r--lib/sqlalchemy/testing/exclusions.py45
1 files changed, 9 insertions, 36 deletions
diff --git a/lib/sqlalchemy/testing/exclusions.py b/lib/sqlalchemy/testing/exclusions.py
index b2828b107..0c05bf9e9 100644
--- a/lib/sqlalchemy/testing/exclusions.py
+++ b/lib/sqlalchemy/testing/exclusions.py
@@ -35,20 +35,10 @@ class compound(object):
self.fails = set()
self.skips = set()
self.tags = set()
- self.combinations = {}
def __add__(self, other):
return self.add(other)
- def with_combination(self, **kw):
- copy = compound()
- copy.fails.update(self.fails)
- copy.skips.update(self.skips)
- copy.tags.update(self.tags)
- copy.combinations.update((f, kw) for f in copy.fails)
- copy.combinations.update((s, kw) for s in copy.skips)
- return copy
-
def add(self, *others):
copy = compound()
copy.fails.update(self.fails)
@@ -95,7 +85,6 @@ class compound(object):
self.skips.update(other.skips)
self.fails.update(other.fails)
self.tags.update(other.tags)
- self.combinations.update(other.combinations)
def __call__(self, fn):
if hasattr(fn, "_sa_exclusion_extend"):
@@ -118,29 +107,13 @@ class compound(object):
try:
yield
except Exception as ex:
- all_fails._expect_failure(config._current, ex, None)
+ all_fails._expect_failure(config._current, ex)
else:
- all_fails._expect_success(config._current, None)
-
- def _check_combinations(self, combination, predicate):
- if predicate in self.combinations:
- for k, v in combination:
- if (
- k in self.combinations[predicate]
- and self.combinations[predicate][k] != v
- ):
- return False
- return True
+ all_fails._expect_success(config._current)
def _do(self, cfg, fn, *args, **kw):
- if len(args) > 1:
- insp = inspect_getfullargspec(fn)
- combination = list(zip(insp.args[1:], args[1:]))
- else:
- combination = None
-
for skip in self.skips:
- if self._check_combinations(combination, skip) and skip(cfg):
+ if skip(cfg):
msg = "'%s' : %s" % (
config.get_current_test_name(),
skip._as_string(cfg),
@@ -150,14 +123,14 @@ class compound(object):
try:
return_value = fn(*args, **kw)
except Exception as ex:
- self._expect_failure(cfg, ex, combination, name=fn.__name__)
+ self._expect_failure(cfg, ex, name=fn.__name__)
else:
- self._expect_success(cfg, combination, name=fn.__name__)
+ self._expect_success(cfg, name=fn.__name__)
return return_value
- def _expect_failure(self, config, ex, combination, name="block"):
+ def _expect_failure(self, config, ex, name="block"):
for fail in self.fails:
- if self._check_combinations(combination, fail) and fail(config):
+ if fail(config):
if util.py2k:
str_ex = unicode(ex).encode( # noqa: F821
"utf-8", errors="ignore"
@@ -174,12 +147,12 @@ class compound(object):
else:
util.raise_from_cause(ex)
- def _expect_success(self, config, combination, name="block"):
+ def _expect_success(self, config, name="block"):
if not self.fails:
return
for fail in self.fails:
- if self._check_combinations(combination, fail) and fail(config):
+ if fail(config):
raise AssertionError(
"Unexpected success for '%s' (%s)"
% (