Commit 251b10ec authored by Julien Muchembled's avatar Julien Muchembled

Unit tests: make --save more reliable if an empty 'unit_test/Xxx.bak' is removed

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33931 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f6ea216e
import errno
import os
import shutil
import sys
......@@ -16,6 +17,15 @@ data_fs_path = os.environ.get('erp5_tests_data_fs_path',
load = int(os.environ.get('erp5_load_data_fs', 0))
save = int(os.environ.get('erp5_save_data_fs', 0))
_print("Cleaning static files ... ")
static_dir_list = 'Constraint', 'Document', 'PropertySheet', 'Extensions'
for dir in static_dir_list:
try:
shutil.rmtree(os.path.join(instance_home, dir))
except OSError, e:
if e.errno != errno.ENOENT:
raise
if load:
dump_sql = os.path.join(instance_home, 'dump.sql')
if os.path.exists(dump_sql):
......@@ -25,21 +35,11 @@ if load:
else:
os.environ['erp5_tests_recreate_catalog'] = '1'
_print("Restoring static files ... ")
for dir in ('Constraint', 'Document', 'PropertySheet', 'Extensions'):
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)
else:
_print("Cleaning static files ... ")
for dir in ('Constraint', 'Document', 'PropertySheet', 'Extensions'):
for dir in static_dir_list:
full_path = os.path.join(instance_home, dir)
if os.path.exists(full_path):
assert os.path.isdir(full_path)
for f in glob.glob('%s/*' % full_path):
os.unlink(f)
if save and os.path.exists(data_fs_path):
if os.path.exists(full_path + '.bak'):
shutil.copytree(full_path + '.bak', full_path, symlinks=True)
elif save and os.path.exists(data_fs_path):
os.remove(data_fs_path)
if save:
......
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