Commit 60732829 authored by Fabien Morin's avatar Fabien Morin

override some method to be able to display more verbose test reports

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23695 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8c8c0956
......@@ -32,6 +32,9 @@ from AccessControl.SecurityManagement import getSecurityManager
from Products.ERP5Type.tests.utils import DummyMailHost
from AccessControl import Unauthorized
from Testing import ZopeTestCase
from Products.ERP5Type.tests.Sequence import Step, Sequence, SequenceList
from zLOG import LOG
import random
class TestEGovMixin(SecurityTestCase):
"""Usefull methods for eGov Unit Tests."""
......@@ -66,6 +69,44 @@ class TestEGovMixin(SecurityTestCase):
MODIFY = 'Modify portal content'
DELETE = 'Delete objects'
# use modified method to render a more verbose output
def play(self, context, sequence=None, sequence_number=0, quiet=0):
if sequence is None:
for idx, step in enumerate(self._step_list):
step.play(context, sequence=self, quiet=quiet)
# commit transaction after each step
get_transaction().commit()
Sequence.play = play
def play(self, context, sequence=None, quiet=0):
method_name = 'step' + self._method_name
method = getattr(context,method_name)
# We can in same cases replay many times the same step,
# or not playing it at all
nb_replay = random.randrange(0,self._max_replay+1)
if self._required:
if nb_replay==0:
nb_replay=1
for i in range(0,nb_replay):
if not quiet:
ZopeTestCase._print('\n Playing step %s' % self._method_name)
ZopeTestCase._print('\n -> %s' % method.__doc__)
LOG('Step.play', 0, ' Playing step %s' % self._method_name)
LOG('Step.play', 0, ' -> %s' % method.__doc__)
method(sequence=sequence)
Step.play = play
def playSequence(self, sequence_string, quiet=0) :
ZopeTestCase._print('\n\n\n---------------------------------------------------------------------')
ZopeTestCase._print('\nStarting New Sequence %s :' % self._TestCase__testMethodName)
ZopeTestCase._print('\n * %s... \n' % self._TestCase__testMethodDoc)
LOG('Sequence.play', 0, 'Starting New Sequence %s :' % self._TestCase__testMethodName)
LOG('Sequence.play', 0, ' * %s... \n' % self._TestCase__testMethodDoc)
sequence_list = SequenceList()
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def getBusinessTemplateList(self):
"""return list of business templates to be installed. """
return ( 'erp5_base',)
......
309
\ No newline at end of file
318
\ No newline at end of file
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