summaryrefslogtreecommitdiffstats
path: root/ipatests
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-09-24 13:46:09 +0200
committerPetr Viktorin <pviktori@redhat.com>2013-10-03 19:50:35 +0200
commit0ad339a73134d08aebe9a6f72b001816bdcb9c1d (patch)
treeaa0d5e7a8f35e21bbdf975ecff7a07ebb139f7cc /ipatests
parenta942ab4f122dceaa075cff0525bf7a4bda04cafe (diff)
downloadfreeipa.git-0ad339a73134d08aebe9a6f72b001816bdcb9c1d.tar.gz
freeipa.git-0ad339a73134d08aebe9a6f72b001816bdcb9c1d.tar.xz
freeipa.git-0ad339a73134d08aebe9a6f72b001816bdcb9c1d.zip
ipatests.order_plugin: Exclude test generators from the order
Ordered test generators were not announced in plugin hooks, so e.g. the Beakerlib or collect plugin did not announce them. Exclude test generators from ordering.
Diffstat (limited to 'ipatests')
-rw-r--r--ipatests/order_plugin.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/ipatests/order_plugin.py b/ipatests/order_plugin.py
index 4e7ec04d..9ecff32a 100644
--- a/ipatests/order_plugin.py
+++ b/ipatests/order_plugin.py
@@ -25,10 +25,19 @@ import inspect
from nose.plugins import Plugin
import nose.loader
+import nose.util
def ordered(cls):
- """Decorator that marks a test class as ordered"""
+ """Decorator that marks a test class as ordered
+
+ Methods within the marked class will be executed in definition order
+ (or more strictly, in ordered by the line number where they're defined).
+
+ Subclasses of unittest.TestCase can not be ordered.
+
+ Generator methods will not be ordered by this plugin.
+ """
cls._order_plugin__ordered = True
assert not isinstance(cls, unittest.TestCase), (
"A unittest.TestCase may not be ordered.")
@@ -56,6 +65,8 @@ class OrderTests(Plugin):
item = getattr(cls, attr, None)
if not inspect.ismethod(item):
return False
+ if nose.util.isgenerator(item.im_func):
+ return False
return loader.selector.wantMethod(item)
methods = [getattr(cls, case) for case in dir(cls) if wanted(case)]
@@ -67,4 +78,6 @@ class OrderTests(Plugin):
"""Hide non-TestCase methods from the normal loader"""
im_class = getattr(method, 'im_class', None)
if im_class and getattr(im_class, '_order_plugin__ordered', False):
+ if nose.util.isgenerator(method.im_func):
+ return True
return False