[Erp5-report] r9896 - /erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Sep 13 23:28:55 CEST 2006


Author: jerome
Date: Wed Sep 13 23:28:53 2006
New Revision: 9896

URL: http://svn.erp5.org?rev=9896&view=rev
Log:
if installing a business template fails, reraise the error and keep a flag not
to try installing it again for other tests.
real error traceback was sometimes lost in the first "finally:" block. For
instance, testAccounting_l10n_fr_m9 was failing due to a max_allowed_packet
problem, but the error message was from ZODB Connection, because
get_transaction().commit() raised a second exception hidding the first one.

This means that if a site cannot be installed, the first test will be a
failure with the real traceback and all other tests will only get an
"Installation of this site already failed, giving up" error.


Modified:
    erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py

Modified: erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py?rev=9896&r1=9895&r2=9896&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py (original)
+++ erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py Wed Sep 13 23:28:53 2006
@@ -141,6 +141,10 @@
 from Products.ERP5.ERP5Site import ERP5Site
 
 portal_name = 'erp5_portal'
+
+# we keep a reference to all sites for wich setup failed the first time, to
+# prevent replaying the same failing setup step for each test.
+failed_portal_installation = {}
 
 class ERP5TypeTestCase(PortalTestCase):
 
@@ -387,6 +391,9 @@
       business_template_list must be specified correctly
       (e.g. '("erp5_common", )').
     '''
+    if portal_name in failed_portal_installation:
+      raise RuntimeError, 'Installation of %s already failed, giving up'\
+                            % portal_name
     try:
       if app is None:
         app = ZopeTestCase.app()
@@ -498,7 +505,10 @@
           if not quiet:
             ZopeTestCase._print('done (%.3fs)\n' % (time.time()-_start,))
             ZopeTestCase._print('Ran Unit test of %s\n' % title)
-        finally:
+        except:
+          get_transaction().abort()
+          raise
+        else:
           get_transaction().commit()
           ZopeTestCase.close(app)
     except:
@@ -506,6 +516,8 @@
       traceback.print_exc(file=f)
       ZopeTestCase._print(f.getvalue())
       f.close()
+      failed_portal_installation[portal_name] = 1
+      raise
 
 def optimize():
   '''Significantly reduces portal creation time.'''




More information about the Erp5-report mailing list