diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-07-27 18:46:20 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-07-27 18:46:20 -0400 |
commit | 54592942c4a9c3d6d891519082555f8081026445 (patch) | |
tree | 29abeff4dee0960284e03558ff464ffbf41cc784 /lib/sqlalchemy/testing/exclusions.py | |
parent | 35551841c522d8eb20f8e20243a5510de9d95dfc (diff) | |
download | sqlalchemy-54592942c4a9c3d6d891519082555f8081026445.tar.gz |
- add support for tags, including include/exclude support.
simplify tox again now that we can exclude tests more easily
Diffstat (limited to 'lib/sqlalchemy/testing/exclusions.py')
-rw-r--r-- | lib/sqlalchemy/testing/exclusions.py | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/sqlalchemy/testing/exclusions.py b/lib/sqlalchemy/testing/exclusions.py index f6ef72408..283d89e36 100644 --- a/lib/sqlalchemy/testing/exclusions.py +++ b/lib/sqlalchemy/testing/exclusions.py @@ -33,6 +33,7 @@ class compound(object): def __init__(self): self.fails = set() self.skips = set() + self.tags = set() def __add__(self, other): return self.add(other) @@ -41,15 +42,18 @@ class compound(object): copy = compound() copy.fails.update(self.fails) copy.skips.update(self.skips) + copy.tags.update(self.tags) for other in others: copy.fails.update(other.fails) copy.skips.update(other.skips) + copy.tags.update(other.tags) return copy def not_(self): copy = compound() copy.fails.update(NotPredicate(fail) for fail in self.fails) copy.skips.update(NotPredicate(skip) for skip in self.skips) + copy.tags.update(self.tags) return copy @property @@ -70,23 +74,29 @@ class compound(object): if predicate(config) ] + def include_test(self, include_tags, exclude_tags): + return bool( + not self.tags.intersection(exclude_tags) and + (not include_tags or self.tags.intersection(include_tags)) + ) + + def _extend(self, other): + self.skips.update(other.skips) + self.fails.update(other.fails) + self.tags.update(other.tags) + def __call__(self, fn): if hasattr(fn, '_sa_exclusion_extend'): - fn._sa_exclusion_extend(self) + fn._sa_exclusion_extend._extend(self) return fn - def extend(other): - self.skips.update(other.skips) - self.fails.update(other.fails) - @decorator def decorate(fn, *args, **kw): return self._do(config._current, fn, *args, **kw) decorated = decorate(fn) - decorated._sa_exclusion_extend = extend + decorated._sa_exclusion_extend = self return decorated - @contextlib.contextmanager def fail_if(self): all_fails = compound() @@ -144,6 +154,16 @@ class compound(object): ) +def requires_tag(tagname): + return tags([tagname]) + + +def tags(tagnames): + comp = compound() + comp.tags.update(tagnames) + return comp + + def only_if(predicate, reason=None): predicate = _as_predicate(predicate) return skip_if(NotPredicate(predicate), reason) |