[Erp5-report] r9828 - /erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Sep 12 11:04:17 CEST 2006


Author: vincent
Date: Tue Sep 12 11:04:15 2006
New Revision: 9828

URL: http://svn.erp5.org?rev=9828&view=rev
Log:
Add error printing function.

Modified:
    erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py

Modified: erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py?rev=9828&r1=9827&r2=9828&view=diff
==============================================================================
--- erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py (original)
+++ erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py Tue Sep 12 11:04:15 2006
@@ -31,6 +31,8 @@
 from time import time, sleep
 from ClientForm import ItemNotFoundError
 from random import randint
+import traceback
+import sys
 
 class LoginError: pass
 
@@ -506,5 +508,27 @@
   return TimeResult(id, start, stop, test_start, test_stop)
 
 def doSleep(min_sleep, max_sleep, lazyness=1):
+  """
+    Sleep for a random duration with a min and max, with a lazyness
+    coeficient.
+  """
   sleep(randint(min_sleep, max_sleep) * lazyness)
 
+def print_error(url, name, result):
+  """
+    Print the backtrace of a test error.
+    url and name are used to identify who and which zope caused an error in a
+    test.
+    result is a list of TimeResult as returned by timeExecution.
+
+    Note that the displayed error is *not* what you can find in the zope
+    error log. This error will only tell which step failed, and the reason -
+    most likely a missing link or input (...) in a page.
+  """
+  sys.stderr.write('-- %s %s --\n' % (url, name))
+  if len(result):
+    sys.stderr.write('Id of last successfull step : %s\n' % (repr(result[-1].getId()), ))
+  else:
+    sys.stderr.write('No step was successfull.')
+  traceback.print_exc()
+




More information about the Erp5-report mailing list