Commit 76ce2d58 authored by Vincent Pelletier's avatar Vincent Pelletier

Add todo_erp5 decorator for unit tests.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25450 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e64c2b87
...@@ -233,3 +233,28 @@ class reindex(object): ...@@ -233,3 +233,28 @@ class reindex(object):
self._instance.tic() self._instance.tic()
return ret 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment