Commit e3a5d825 authored by Jérome Perrin's avatar Jérome Perrin

ERP5Type/tests/Sequence: be quiet by default

Sequence produce lots of useless output, which makes it slow to display test
result pages for tests using sequences, like testBusinesTemplate.
It must also be taking a lot of disk space on the server and is generally
not useful, when a test fail we have the log of the failing test.
parent e8cb8cba
Pipeline #15371 failed with stage
...@@ -75,7 +75,7 @@ class Step: ...@@ -75,7 +75,7 @@ class Step:
self._required = required self._required = required
self._max_replay = max_replay self._max_replay = max_replay
def play(self, context, sequence=None, quiet=0): def play(self, context, sequence=None, quiet=True):
method_name = 'step' + self._method_name method_name = 'step' + self._method_name
method = getattr(context,method_name) method = getattr(context,method_name)
# We can in same cases replay many times the same step, # We can in same cases replay many times the same step,
...@@ -119,7 +119,7 @@ class Sequence: ...@@ -119,7 +119,7 @@ class Sequence:
line_list.append(' %s' % step._method_name) line_list.append(' %s' % step._method_name)
return '\n'.join(line_list) return '\n'.join(line_list)
def play(self, context, sequence=None, sequence_number=0, quiet=0): def play(self, context, sequence=None, sequence_number=0, quiet=True):
if not quiet: if not quiet:
if self._played_index == 0: if self._played_index == 0:
ZopeTestCase._print('\nStarting New Sequence %i... ' % sequence_number) ZopeTestCase._print('\nStarting New Sequence %i... ' % sequence_number)
...@@ -149,7 +149,7 @@ class Sequence: ...@@ -149,7 +149,7 @@ class Sequence:
def setdefault(self, key, default=None): def setdefault(self, key, default=None):
return self._dict.setdefault(key, default) return self._dict.setdefault(key, default)
def __call__(self, sequence_string, sequence_number=0, quiet=0): def __call__(self, sequence_string, sequence_number=0, quiet=True):
""" """
add some steps and directly runs them, this allows to easily write add some steps and directly runs them, this allows to easily write
such code when sequence are unable to handle too complex cases : such code when sequence are unable to handle too complex cases :
...@@ -311,7 +311,7 @@ class SequenceList: ...@@ -311,7 +311,7 @@ class SequenceList:
self.addSequence(sequence) self.addSequence(sequence)
return sequence return sequence
def play(self, context, quiet=0): def play(self, context, quiet=True):
i = 1 i = 1
for sequence in self._sequence_list: for sequence in self._sequence_list:
sequence._played_index = 0 sequence._played_index = 0
......
  • @jerome I agree with the idea 'quiet by default'. But still I prefer having the progress when I run a test manually with -D option.

    How about the following change ?

    --- product/ERP5Type/tests/Sequence.py
    +++ product/ERP5Type/tests/Sequence.py
    @@ -28,6 +28,7 @@
     
     from Testing import ZopeTestCase
     from zLOG import LOG
    +import os
     import random
     
     
    @@ -313,7 +314,7 @@ class SequenceList:
         self.addSequence(sequence)
         return sequence
     
    -  def play(self, context, quiet=True):
    +  def play(self, context, quiet=not os.environ.get('erp5_debug_mode')):
         i = 1
         for sequence in self._sequence_list:
           sequence._played_index = 0

    Maybe non-quiet is preferrable while running live test as well ?

    /cc @georgios.dagkakis

  • Isn't this following the --verbose argument of runUnitTest ? If you run with -v -D don't you see the detailed output ? In ComponentTool_viewLiveTestDialog there is a "verbose" checkbox that should also do the same thing.

  • No, I see no detailed output even with -v -D. Do we have such code ?

  • I noticed this change in live tests. I have Verbose checked and I get no steps in the gadget unless some fails. Even if I check Debug it is the same

  • ah thanks for trying, apparently we don't. We do things like https://lab.nexedi.com/nexedi/erp5/blob/a3f01a7a9a2f17312310e6bcfb70bb96b9f78ff7/bt5/erp5_trade/TestTemplateItem/portal_components/test.erp5.testPackingList.py#L1102 , but quiet is defined as a class attribute https://lab.nexedi.com/nexedi/erp5/blob/a3f01a7a9a2f17312310e6bcfb70bb96b9f78ff7/bt5/erp5_trade/TestTemplateItem/portal_components/test.erp5.testPackingList.py#L1038

    Anyway, how about doing something similar as you suggest, but depending on -v and not -D ? I don't use sequence test so much and I don't care about output so I don't have objections regarding one way or another

    Edited by Jérome Perrin
  • as we see in testPackingList, we have tests hardcoding the quiet, this (and the run=run_all_tests as well) can all be removed I think

  • but depending on -v and not -D

    my gut feeling is the same. verbose is what I'd expect to make the steps shown

  • Yes, it should be -v, not -D.

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