[Erp5-report] r25450 - /erp5/trunk/products/ERP5Type/tests/utils.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Feb 4 18:26:35 CET 2009
Author: vincent
Date: Wed Feb 4 18:26:32 2009
New Revision: 25450
URL: http://svn.erp5.org?rev=25450&view=rev
Log:
Add todo_erp5 decorator for unit tests.
Modified:
erp5/trunk/products/ERP5Type/tests/utils.py
Modified: erp5/trunk/products/ERP5Type/tests/utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/utils.py?rev=25450&r1=25449&r2=25450&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/utils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/utils.py [utf8] Wed Feb 4 18:26:32 2009
@@ -233,3 +233,28 @@
self._instance.tic()
return ret
+def todo_erp5(function):
+ """
+ Use this function as a decorator around a test method to tag it as TODO.
+ Tagging as TODO means that:
+ - a failure (AssertionError exception) is expected, and will not be
+ reported as a failure in test report.
+ - a success or any other exception is *not* expected, and will cause the
+ test to be reported as failed.
+
+ Inspired from Wine's tests (http://www.winehq.org).
+ """
+ func_code = function.func_code
+ function_id = '%s:%s %s' % (func_code.co_filename, func_code.co_firstlineno,
+ func_code.co_name)
+ def wrapper(*args, **kw):
+ try:
+ result = function(*args, **kw)
+ except AssertionError:
+ LOG('TODO', 0, function_id)
+ print 'TODO: %s' % (function_id, )
+ else:
+ raise AssertionError, '%s Succeeded although being tagged as TODO' % (function_id, )
+ wrapper.__name__ = function.__name__
+ return wrapper
+
More information about the Erp5-report
mailing list