[py-svn] r62614 - in py/trunk/py: . misc/testing
hpk at codespeak.net
hpk at codespeak.net
Thu Mar 5 23:35:38 CET 2009
Author: hpk
Date: Thu Mar 5 23:35:35 2009
New Revision: 62614
Modified:
py/trunk/py/_com.py
py/trunk/py/misc/testing/test_com.py
Log:
implementing __call__.exclude_other_results() to allow plugin hooks to
exclude results from other plugins.
Modified: py/trunk/py/_com.py
==============================================================================
--- py/trunk/py/_com.py (original)
+++ py/trunk/py/_com.py Thu Mar 5 23:35:35 2009
@@ -52,6 +52,9 @@
res = self.currentmethod(self, *self.args, **self.kwargs)
else:
res = self.currentmethod(*self.args, **self.kwargs)
+ if hasattr(self, '_ex1'):
+ self.results = [res]
+ break
if res is not None:
if res is self.NONEASRESULT:
res = None
@@ -63,6 +66,9 @@
if self.results:
return self.results[-1]
+ def exclude_other_results(self):
+ self._ex1 = True
+
class PyPlugins:
"""
Manage Plugins: Load plugins and manage calls to plugins.
Modified: py/trunk/py/misc/testing/test_com.py
==============================================================================
--- py/trunk/py/misc/testing/test_com.py (original)
+++ py/trunk/py/misc/testing/test_com.py Thu Mar 5 23:35:35 2009
@@ -49,6 +49,22 @@
call = MultiCall([n, m])
res = call.execute(firstresult=True)
assert res == 2
+
+ def test_call_exclude_other_results(self):
+ def m(__call__):
+ __call__.exclude_other_results()
+ return 10
+
+ def n():
+ return 1
+
+ call = MultiCall([n, n, m, n])
+ res = call.execute()
+ assert res == [10]
+ # doesn't really make sense for firstresult-mode - because
+ # we might not have had a chance to run at all.
+ #res = call.execute(firstresult=True)
+ #assert res == 10
class TestPyPlugins:
More information about the pytest-commit
mailing list