diff --git a/product/ERP5Type/tests/ERP5TypeTestCase.py b/product/ERP5Type/tests/ERP5TypeTestCase.py index 659ca99c0341956cc1c3d438d238c339b2da6afd..2adc21d57251b61ae1d0aba979fd546be5276c58 100644 --- a/product/ERP5Type/tests/ERP5TypeTestCase.py +++ b/product/ERP5Type/tests/ERP5TypeTestCase.py @@ -15,6 +15,7 @@ import os import random import re import socket +import shutil import sys import time import traceback @@ -1016,6 +1017,28 @@ class ERP5TypeTestCase(ProcessingNodeTestCase, PortalTestCase): transaction.commit() self.tic() + def copyInputFileToImportFolder(self, relative_path): + """ + Copies a file located in $TESTFILEDIR/input/ to + import/ folder of test instance and returns the + full path. + If files already exists, overwrites it. + """ + test_path = os.path.dirname(__file__) + + source_path = os.path.join(test_path, 'input', relative_path) + self.assertTrue(os.path.exists(source_path)) + + import_path = os.path.join(instancehome, 'import') + if not os.path.exists(import_path): + if os.path.islink(import_path): + # broken symlink + os.unlink(import_path) + os.mkdir(import_path) + + shutil.copy(source_path, import_path) + return import_path + def publish(self, path, basic=None, env=None, extra=None, request_method='GET', stdin=None, handle_errors=True): '''Publishes the object at 'path' returning a response object.''' diff --git a/product/ERP5Type/tests/testDynamicClassGeneration.py b/product/ERP5Type/tests/testDynamicClassGeneration.py index a44e235c0cdcc81fd3f5b2e188fdfbf88372a2fb..38050dcd4dc5e6b08e1737a647fa90dce826904a 100644 --- a/product/ERP5Type/tests/testDynamicClassGeneration.py +++ b/product/ERP5Type/tests/testDynamicClassGeneration.py @@ -28,7 +28,6 @@ # ############################################################################## -import os, shutil import unittest import transaction @@ -46,22 +45,8 @@ class TestPortalTypeClass(ERP5TypeTestCase): Products.ERP5Type.Document.Person.Person type """ file_name = 'non_migrated_person.zexp' - import Products.ERP5Type.tests as test_module - test_path = test_module.__path__ - if isinstance(test_path, list): - test_path = test_path[0] - - zexp_path = os.path.join(test_path, 'input', file_name) - self.assertTrue(os.path.exists(zexp_path)) - - import_path = os.path.join(os.environ['INSTANCE_HOME'], 'import') - if not os.path.exists(import_path): - if os.path.islink(import_path): - # broken symlink - os.unlink(import_path) - os.mkdir(import_path) - - shutil.copy(zexp_path, import_path) + + self.copyInputFileToImportFolder(file_name) person_module = self.getPortal().person_module person_module.manage_importObject(file_name)