[Erp5-report] r24091 - /erp5/trunk/products/ERP5Type/tests/custom_zodb.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Oct 8 10:41:07 CEST 2008


Author: jerome
Date: Wed Oct  8 10:41:03 2008
New Revision: 24091

URL: http://svn.erp5.org?rev=24091&view=rev
Log:
use shutil module instead of os.system
split assert statement in two statements

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

Modified: erp5/trunk/products/ERP5Type/tests/custom_zodb.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/custom_zodb.py?rev=24091&r1=24090&r2=24091&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/custom_zodb.py (original)
+++ erp5/trunk/products/ERP5Type/tests/custom_zodb.py Wed Oct  8 10:41:03 2008
@@ -1,5 +1,6 @@
+import os
+import shutil
 import ZODB
-import os
 from ZODB.DemoStorage import DemoStorage
 from ZODB.FileStorage import FileStorage
 from Products.ERP5Type.tests.utils import getMySQLArguments
@@ -14,19 +15,22 @@
   else:
     Storage = DemoStorage(base=FileStorage(new_data_fs_path), quota=(1<<20))
   print("Restoring MySQL database ... ")
-  assert os.system("mysql %s < %s/dump.sql" % (
-                getMySQLArguments(), instance_home)) == 0
+  ret = os.system("mysql %s < %s/dump.sql" % (
+                getMySQLArguments(), instance_home))
+  assert ret == 0
   print("Restoring static files ... ")
   for dir in ('Constraint', 'Document', 'PropertySheet', 'Extensions'):
-    if os.path.exists('%s/%s.bak' % (instance_home, dir)):
-      assert os.system('rm -rf %s/%s' % (instance_home, dir)) == 0
-      assert os.system('cp -ar %s/%s.bak %s/%s' % (
-                instance_home, dir, instance_home, dir)) == 0
+    if os.path.exists(os.path.join(instance_home, '%s.bak' % dir)):
+      full_path = os.path.join(instance_home, dir)
+      shutil.rmtree(full_path)
+      shutil.copytree(os.path.join(instance_home, '%s.bak' % dir),
+                      full_path, symlinks=True)
 elif os.environ.get('erp5_save_data_fs'):
   print("Cleaning static files ... ")
   for dir in ('Constraint', 'Document', 'PropertySheet', 'Extensions'):
-    if os.path.exists('%s/%s' % (instance_home, dir)):
-      assert os.system('rm -f %s/%s/*' % (instance_home, dir)) == 0
+    full_path = os.path.join(instance_home, dir)
+    if os.path.exists(full_path):
+      shutil.rmtree(full_path)
   if os.path.exists(new_data_fs_path):
     os.remove(new_data_fs_path)
   Storage = FileStorage(new_data_fs_path)




More information about the Erp5-report mailing list