Commit 9e18caf2 authored by Nicolas Dumazet's avatar Nicolas Dumazet

enhance todo_erp5 with backportUnittest.skip: tests tagged with this decorator

will now be skipped.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30087 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 32f531b9
...@@ -40,6 +40,8 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed ...@@ -40,6 +40,8 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.ERP5Type.Base import _aq_reset from Products.ERP5Type.Base import _aq_reset
from zLOG import LOG, DEBUG from zLOG import LOG, DEBUG
import backportUnittest
# Quiet messages when installing products # Quiet messages when installing products
install_product_quiet = 1 install_product_quiet = 1
# Quiet messages when installing business templates # Quiet messages when installing business templates
...@@ -218,7 +220,7 @@ def profile_if_environ(environment_var_name): ...@@ -218,7 +220,7 @@ def profile_if_environ(environment_var_name):
# No profiling, return identity decorator # No profiling, return identity decorator
return lambda self, method: method return lambda self, method: method
class ERP5TypeTestCase(PortalTestCase): class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase):
"""TestCase for ERP5 based tests. """TestCase for ERP5 based tests.
This TestCase setups an ERP5Site and installs business templates. This TestCase setups an ERP5Site and installs business templates.
......
...@@ -8,8 +8,9 @@ import unittest ...@@ -8,8 +8,9 @@ import unittest
import shutil import shutil
import errno import errno
WIN = os.name == 'nt' import backportUnittest
WIN = os.name == 'nt'
__doc__ = """%(program)s: unit test runner for the ERP5 Project __doc__ = """%(program)s: unit test runner for the ERP5 Project
...@@ -282,7 +283,7 @@ def runUnitTestList(test_list, verbosity=1, debug=0): ...@@ -282,7 +283,7 @@ def runUnitTestList(test_list, verbosity=1, debug=0):
except ImportError: except ImportError:
pass pass
TestRunner = unittest.TextTestRunner TestRunner = backportUnittest.TextTestRunner
suite = unittest.TestSuite() suite = unittest.TestSuite()
# allow unit tests of our Products or business templates to be reached. # allow unit tests of our Products or business templates to be reached.
......
...@@ -36,6 +36,8 @@ import Products.ERP5Type ...@@ -36,6 +36,8 @@ import Products.ERP5Type
from Products.MailHost.MailHost import MailHost from Products.MailHost.MailHost import MailHost
from zLOG import LOG from zLOG import LOG
import backportUnittest
class FileUpload(file): class FileUpload(file):
"""Act as an uploaded file. """Act as an uploaded file.
""" """
...@@ -240,28 +242,11 @@ class reindex(object): ...@@ -240,28 +242,11 @@ class reindex(object):
self._instance.tic() self._instance.tic()
return ret return ret
def todo_erp5(function): # Use this as a method or class decorator to tag it as TODO.
""" # The test will be skipped:
Use this function as a decorator around a test method to tag it as TODO. # - the fixture itself is not run
Tagging as TODO means that: # - if a TODO test is in fact successful, no one will ever know
- a failure (AssertionError exception) is expected, and will not be #
reported as a failure in test report. # Test cases using this decorator must extend backportUnittest.TestCase
- a success or any other exception is *not* expected, and will cause the todo_erp5 = backportUnittest.skip("TODO ERP5")
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