From 3b9b73089473ac7bbe00938fc363bc81d9534adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 5 Sep 2007 09:57:00 +0000 Subject: [PATCH] =?UTF-8?q?patches=20from=20Klaus=20W=C3=B6lfel=20for=20po?= =?UTF-8?q?rtability:=20=20=20open=20files=20in=20correct=20binary=20or=20?= =?UTF-8?q?text=20mode=20=20=20use=20os.path=20join=20=20=20use=20=5F=5Ffi?= =?UTF-8?q?le=5F=5F=20instead=20of=20looking=20in=20instance/software=20ho?= =?UTF-8?q?me?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16066 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/PDFForm.py | 4 ++-- product/ERP5Form/tests/testPDFForm.py | 2 +- product/ERP5OOo/tests/testDms.py | 4 ++-- product/ERP5OOo/tests/testIngestion.py | 4 ++-- product/ERP5OOo/tests/testOOoBatchMode.py | 16 ++-------------- product/ERP5OOo/tests/testOOoImport.py | 4 ++-- 6 files changed, 11 insertions(+), 23 deletions(-) diff --git a/product/ERP5Form/PDFForm.py b/product/ERP5Form/PDFForm.py index dfa2c1f1a1..b778d5ff6c 100644 --- a/product/ERP5Form/PDFForm.py +++ b/product/ERP5Form/PDFForm.py @@ -96,13 +96,13 @@ class PDFTk: if hasattr(pdfFile, "read") : pdfFile = pdfFile.read() - tmpPdfFile = open(pdfFormFileName, "w") + tmpPdfFile = open(pdfFormFileName, "wb") tmpPdfFile.write(pdfFile) tmpPdfFile.close() if hasattr(fdfFile, "read") : fdfFile = fdfFile.read() - tmpFdfFile = open(fdfFormFileName, "w") + tmpFdfFile = open(fdfFormFileName, "wb") tmpFdfFile.write(fdfFile) tmpFdfFile.close() diff --git a/product/ERP5Form/tests/testPDFForm.py b/product/ERP5Form/tests/testPDFForm.py index 86c849581c..8862f0460c 100644 --- a/product/ERP5Form/tests/testPDFForm.py +++ b/product/ERP5Form/tests/testPDFForm.py @@ -41,7 +41,7 @@ class TestPDFForm(unittest.TestCase): """ self.document = Document('doc_id') pdf_file = open(os.path.join(os.path.dirname(__file__), - 'data', 'test_1.pdf')) + 'data', 'test_1.pdf'), 'rb') self.pdf_form = PDFForm('test_pdf_form').__of__(self.document) self.pdf_form.manage_upload(pdf_file) diff --git a/product/ERP5OOo/tests/testDms.py b/product/ERP5OOo/tests/testDms.py index f878062f1d..a47fbe14c9 100644 --- a/product/ERP5OOo/tests/testDms.py +++ b/product/ERP5OOo/tests/testDms.py @@ -80,7 +80,7 @@ RUN_ALL_TEST = 1 # Define the conversion server host conversion_server_host = ('127.0.0.1', 8008) -TEST_FILES_HOME = os.path.join(os.getenv('INSTANCE_HOME'), 'Products', 'ERP5OOo', 'tests', 'test_document') +TEST_FILES_HOME = os.path.join(os.path.dirname(__file__), 'test_document') FILE_NAME_REGULAR_EXPRESSION = "(?P<reference>[A-Z]{3,6})-(?P<language>[a-z]{2})-(?P<version>[0-9]{3})" REFERENCE_REGULAR_EXPRESSION = "(?P<reference>[A-Z]{3,6})(-(?P<language>[a-z]{2}))?(-(?P<version>[0-9]{3}))?" @@ -193,7 +193,7 @@ class TestDocument(ERP5TypeTestCase): dm=self.getPortal().document_module doctext=dm.newContent(portal_type=portal_type) if file_name is not None: - f = open(makeFilePath(file_name)) + f = open(makeFilePath(file_name), 'rb') doctext.setTextContent(f.read()) f.close() doctext.setReference(reference) diff --git a/product/ERP5OOo/tests/testIngestion.py b/product/ERP5OOo/tests/testIngestion.py index 9c5e801735..9f742b5c7c 100644 --- a/product/ERP5OOo/tests/testIngestion.py +++ b/product/ERP5OOo/tests/testIngestion.py @@ -51,7 +51,7 @@ os.environ['EVENT_LOG_SEVERITY'] = '-300' conversion_server_host = ('127.0.0.1', 8008) # test files' home -TEST_FILES_HOME = os.path.join(os.getenv('INSTANCE_HOME'), 'Products', 'ERP5OOo', 'tests', 'test_document') +TEST_FILES_HOME = os.path.join(os.path.dirname(__file__), 'test_document') FILE_NAME_REGULAR_EXPRESSION = "(?P<reference>[A-Z]{3,6})-(?P<language>[a-z]{2})-(?P<version>[0-9]{3})" REFERENCE_REGULAR_EXPRESSION = "(?P<reference>[A-Z]{3,6})(-(?P<language>[a-z]{2}))?(-(?P<version>[0-9]{3}))?" @@ -71,7 +71,7 @@ class FileUploadTest(file): def __init__(self, path, name): self.filename = name - file.__init__(self, path) + file.__init__(self, path, 'rb') self.headers = {} def makeFilePath(name): diff --git a/product/ERP5OOo/tests/testOOoBatchMode.py b/product/ERP5OOo/tests/testOOoBatchMode.py index b345797a7c..f5dbaa10ec 100644 --- a/product/ERP5OOo/tests/testOOoBatchMode.py +++ b/product/ERP5OOo/tests/testOOoBatchMode.py @@ -60,20 +60,8 @@ class TestOoodResponse(ERP5TypeTestCase): self.login() portal_skins = self.getSkinsTool() portal_skins.custom.REQUEST.RESPONSE.setHeader('content-type', 'text/html') - try: - import_file_path = os.path.join(getConfiguration().instancehome, - 'Products', - 'ERP5OOo', - 'tests', - 'PersonSpreadsheetStylesheet' ) - except IOError: - import_file_path = os.path.join(getConfiguration().softwarehome, - 'Products', - 'ERP5OOo', - 'tests', - 'PersonSpreadsheetStylesheet') - - import_file = open(import_file_path) + import_file_path = os.path.join(os.path.dirname(__file__), 'PersonSpreadsheetStylesheet') + import_file = open(import_file_path, 'rb') addStyleSheet = portal_skins.custom.manage_addProduct['OFSP'].manage_addFile addStyleSheet(id='Base_getODTStyleSheet', file=import_file, title='', precondition='', content_type='application/vnd.oasis.opendocument.text') addOOoTemplate = portal_skins.custom.manage_addProduct['ERP5OOo'].addOOoTemplate diff --git a/product/ERP5OOo/tests/testOOoImport.py b/product/ERP5OOo/tests/testOOoImport.py index a84117e1bc..c6afaac7b7 100644 --- a/product/ERP5OOo/tests/testOOoImport.py +++ b/product/ERP5OOo/tests/testOOoImport.py @@ -81,11 +81,11 @@ class FileUploadTest(file): def __init__(self, path, name): self.filename = name - file.__init__(self, path) + file.__init__(self, path, 'rb') self.headers = {} def makeFilePath(name): - return os.getenv('INSTANCE_HOME') + '/../Products/ERP5OOo/tests/test_document/' + name + return os.path.join(os.path.dirname(__file__), 'test_document', name) def makeFileUpload(name): path = makeFilePath(name) -- 2.30.9