From 396743f9d7e8eb9fbca3e9f97e7f2dbceb486f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Sun, 16 Sep 2007 19:36:09 +0000 Subject: [PATCH] fix all name errors / unused imports in ERP5Type/tests git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16394 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/tests/framework.py | 3 ++ .../ERP5Type/tests/namingConventionTest.py | 21 ++------- .../ERP5Type/tests/prepareFunctionalTest.py | 22 +++------ product/ERP5Type/tests/sendMail.py | 3 -- product/ERP5Type/tests/testCacheTool.py | 23 +++------- product/ERP5Type/tests/testCachedSkinsTool.py | 2 + product/ERP5Type/tests/testClassTool.py | 1 - product/ERP5Type/tests/testConstraint.py | 22 +++------ product/ERP5Type/tests/testERP5Type.py | 22 ++------- product/ERP5Type/tests/testFolder.py | 46 ++++++++++++------- product/ERP5Type/tests/testFolderMigration.py | 23 +++------- product/ERP5Type/tests/testMemcachedTool.py | 3 +- product/ERP5Type/tests/testPerformance.py | 28 +++-------- product/ERP5Type/tests/testSessionTool.py | 21 ++------- product/ERP5Type/tests/testTimerService.py | 20 ++------ .../tests/testTransactionalVariable.py | 21 ++------- product/ERP5Type/tests/testXMLMatrix.py | 25 +++------- 17 files changed, 99 insertions(+), 207 deletions(-) diff --git a/product/ERP5Type/tests/framework.py b/product/ERP5Type/tests/framework.py index 7ccab93b10..06e312d377 100644 --- a/product/ERP5Type/tests/framework.py +++ b/product/ERP5Type/tests/framework.py @@ -37,6 +37,9 @@ # ############################################################################## +import os +import sys + __version__ = '0.2.3' # Save start state diff --git a/product/ERP5Type/tests/namingConventionTest.py b/product/ERP5Type/tests/namingConventionTest.py index e60395a364..3e56821a03 100644 --- a/product/ERP5Type/tests/namingConventionTest.py +++ b/product/ERP5Type/tests/namingConventionTest.py @@ -32,15 +32,8 @@ # usage: python runUnitTest.py [OPTION]... namingConventionTest.py # -import os -import sys import re -if __name__ == '__main__': - execfile(os.path.join(sys.path[0], 'framework.py')) - -# Needed in order to have a log file inside the current folder -os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log') -os.environ['EVENT_LOG_SEVERITY'] = '-300' +import unittest from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase @@ -80,11 +73,7 @@ class TestNamingConvention(ERP5TypeTestCase): problems = int(problems_re.search(result).group(1)) self.assertEquals(0, problems, result) -if __name__ == '__main__': - framework() -else: - import unittest - def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestNamingConvention)) - return suite +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestNamingConvention)) + return suite diff --git a/product/ERP5Type/tests/prepareFunctionalTest.py b/product/ERP5Type/tests/prepareFunctionalTest.py index f77a7d2f45..1588c510ae 100755 --- a/product/ERP5Type/tests/prepareFunctionalTest.py +++ b/product/ERP5Type/tests/prepareFunctionalTest.py @@ -33,14 +33,7 @@ # import os -import sys -from time import sleep -if __name__ == '__main__': - execfile(os.path.join(sys.path[0], 'framework.py')) - -# Needed in order to have a log file inside the current folder -os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log') -os.environ['EVENT_LOG_SEVERITY'] = '-300' +import unittest from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase @@ -63,11 +56,8 @@ class TestZelenium(ERP5TypeTestCase): def testInformation(self): self.assert_(False, 'This script is intended to be used with --save option.') -if __name__ == '__main__': - framework() -else: - import unittest - def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestZelenium)) - return suite + +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestZelenium)) + return suite diff --git a/product/ERP5Type/tests/sendMail.py b/product/ERP5Type/tests/sendMail.py index 0165261ddb..a7567e68a7 100644 --- a/product/ERP5Type/tests/sendMail.py +++ b/product/ERP5Type/tests/sendMail.py @@ -31,10 +31,7 @@ import smtplib import re -from datetime import date from email.MIMEText import MIMEText -from email.MIMEBase import MIMEBase -from email.MIMEImage import MIMEImage from email.MIMEMultipart import MIMEMultipart from email.Message import Message diff --git a/product/ERP5Type/tests/testCacheTool.py b/product/ERP5Type/tests/testCacheTool.py index 8d4c351e57..12caa41cd1 100644 --- a/product/ERP5Type/tests/testCacheTool.py +++ b/product/ERP5Type/tests/testCacheTool.py @@ -26,21 +26,14 @@ # ############################################################################## -import os, sys -if __name__ == '__main__': - execfile(os.path.join(sys.path[0], 'framework.py')) - -# Needed in order to have a log file inside the current folder -os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log') -os.environ['EVENT_LOG_SEVERITY'] = '-300' +import time +import unittest from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.CachePlugins.DummyCache import DummyCache -from Products.ERP5Type.Cache import CachingMethod from AccessControl.SecurityManagement import newSecurityManager from zLOG import LOG -import time try: from transaction import get as get_transaction @@ -284,12 +277,8 @@ return result ## Cache cleared shouldn't be previously cached self.assert_(1.0 < calculation_time) -if __name__ == '__main__': - framework() -else: - import unittest - def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestCacheTool)) - return suite +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestCacheTool)) + return suite diff --git a/product/ERP5Type/tests/testCachedSkinsTool.py b/product/ERP5Type/tests/testCachedSkinsTool.py index ca221f750f..5a28b455d0 100644 --- a/product/ERP5Type/tests/testCachedSkinsTool.py +++ b/product/ERP5Type/tests/testCachedSkinsTool.py @@ -26,6 +26,8 @@ # ############################################################################## +import unittest + from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from AccessControl.SecurityManagement import newSecurityManager diff --git a/product/ERP5Type/tests/testClassTool.py b/product/ERP5Type/tests/testClassTool.py index 7a4d6344c0..ef3c8320b2 100644 --- a/product/ERP5Type/tests/testClassTool.py +++ b/product/ERP5Type/tests/testClassTool.py @@ -31,7 +31,6 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from AccessControl.SecurityManagement import newSecurityManager from Products.ERP5Type.tests.utils import installRealClassTool from zLOG import LOG -import time try: from transaction import get as get_transaction diff --git a/product/ERP5Type/tests/testConstraint.py b/product/ERP5Type/tests/testConstraint.py index 7e7fcded7b..6a6b5083c7 100644 --- a/product/ERP5Type/tests/testConstraint.py +++ b/product/ERP5Type/tests/testConstraint.py @@ -25,17 +25,11 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## -import os, sys -if __name__ == '__main__': - execfile(os.path.join(sys.path[0], 'framework.py')) -# Needed in order to have a log file inside the current folder -os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log') -os.environ['EVENT_LOG_SEVERITY'] = '-300' +import unittest from Products.ERP5Type.tests.testERP5Type import PropertySheetTestCase -from AccessControl.SecurityManagement import newSecurityManager, \ - noSecurityManager +from AccessControl.SecurityManagement import newSecurityManager from Products.ERP5Type.tests.Sequence import Sequence, SequenceList class TestConstraint(PropertySheetTestCase): @@ -1314,11 +1308,7 @@ class TestConstraint(PropertySheetTestCase): sequence_list.play(self, quiet=quiet) -if __name__ == '__main__': - framework() -else: - import unittest - def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestConstraint)) - return suite +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestConstraint)) + return suite diff --git a/product/ERP5Type/tests/testERP5Type.py b/product/ERP5Type/tests/testERP5Type.py index f5169d60be..2a104e95dd 100644 --- a/product/ERP5Type/tests/testERP5Type.py +++ b/product/ERP5Type/tests/testERP5Type.py @@ -26,22 +26,14 @@ # ############################################################################## -import os -import sys import md5 -if __name__ == '__main__': - execfile(os.path.join(sys.path[0], 'framework.py')) - -# Needed in order to have a log file inside the current folder -os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log') -os.environ['EVENT_LOG_SEVERITY'] = '-300' +import unittest from random import randint from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from zLOG import LOG, INFO from Products.CMFCore.tests.base.testcase import LogInterceptor -from Products.ERP5Type.Cache import CachingMethod, clearCache from Products.ERP5Type.Base import _aq_reset from Products.ERP5Type.tests.utils import installRealClassTool from Products.ERP5Type.Utils import removeLocalPropertySheet @@ -1355,11 +1347,7 @@ class TestPropertySheet: obj.setFooBar('something') self.assertTrue(obj.hasFooBar()) -if __name__ == '__main__': - framework() -else: - import unittest - def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestERP5Type)) - return suite +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestERP5Type)) + return suite diff --git a/product/ERP5Type/tests/testFolder.py b/product/ERP5Type/tests/testFolder.py index 348f329ea6..04aedf9473 100644 --- a/product/ERP5Type/tests/testFolder.py +++ b/product/ERP5Type/tests/testFolder.py @@ -1,14 +1,32 @@ +############################################################################## # -# ERP5 Folder unit test suite. +# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved. +# Yoshinori Okuji <yo@nexedi.com> # +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## -import os, sys -if __name__ == '__main__': - execfile(os.path.join(sys.path[0], 'framework.py')) - -# Needed in order to have a log file inside the current folder -os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log') -os.environ['EVENT_LOG_SEVERITY'] = '-300' +import unittest from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from zLOG import LOG @@ -152,11 +170,7 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor): self.assertRaises(ValueError, self.folder.newContent, portal_type='Category') -if __name__ == '__main__': - framework() -else: - import unittest - def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestFolder)) - return suite +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestFolder)) + return suite diff --git a/product/ERP5Type/tests/testFolderMigration.py b/product/ERP5Type/tests/testFolderMigration.py index 3dca4ebe4d..bfa6b1e282 100755 --- a/product/ERP5Type/tests/testFolderMigration.py +++ b/product/ERP5Type/tests/testFolderMigration.py @@ -1,3 +1,4 @@ +# -*- coding: latin1 -*- ############################################################################## # # Copyright (c) 2007 Nexedi SARL and Contributors. All Rights Reserved. @@ -26,19 +27,11 @@ # ############################################################################## -import os, sys -if __name__ == '__main__': - execfile(os.path.join(sys.path[0], 'framework.py')) - -# Needed in order to have a log file inside the current folder -os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log') -os.environ['EVENT_LOG_SEVERITY'] = '-300' +import unittest from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from zLOG import LOG from Products.CMFCore.tests.base.testcase import LogInterceptor -from Products.ERP5Type.tests.utils import createZODBPythonScript -from Products.ERP5Type.ERP5Type import ERP5TypeInformation from Products.ERP5Type.Cache import clearCache class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): @@ -126,11 +119,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor): self.assertEquals(obj3.getId(), '%s-3' %date) -if __name__ == '__main__': - framework() -else: - import unittest - def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestFolderMigration)) - return suite +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestFolderMigration)) + return suite diff --git a/product/ERP5Type/tests/testMemcachedTool.py b/product/ERP5Type/tests/testMemcachedTool.py index b72e3e69f2..c29a99bbd4 100644 --- a/product/ERP5Type/tests/testMemcachedTool.py +++ b/product/ERP5Type/tests/testMemcachedTool.py @@ -26,8 +26,9 @@ # ############################################################################## +import unittest + from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase -from Products.ERP5Type.Tool.MemcachedTool import MemcachedTool from AccessControl.SecurityManagement import newSecurityManager from Products.ERP5Type.tests.utils import installRealMemcachedTool diff --git a/product/ERP5Type/tests/testPerformance.py b/product/ERP5Type/tests/testPerformance.py index cfe947ca6f..dc82aa428d 100755 --- a/product/ERP5Type/tests/testPerformance.py +++ b/product/ERP5Type/tests/testPerformance.py @@ -26,23 +26,13 @@ # ############################################################################## -import os, sys -if __name__ == '__main__': - execfile(os.path.join(sys.path[0], 'framework.py')) - -# Needed in order to have a log file inside the current folder -os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log') -os.environ['EVENT_LOG_SEVERITY'] = '-300' +import unittest +from time import time +import gc from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from zLOG import LOG from Products.CMFCore.tests.base.testcase import LogInterceptor -from Products.ERP5Type.tests.utils import createZODBPythonScript -from Products.ERP5Type.ERP5Type import ERP5TypeInformation -from Products.ERP5Type.Cache import clearCache -from DateTime import DateTime -from time import time -import gc # Define variable to chek if performance are good or not # XXX These variable are specific to the testing environment @@ -183,11 +173,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor): self.failUnless(MIN_TIC < tic_value < MAX_TIC) i += 1 -if __name__ == '__main__': - framework() -else: - import unittest - def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestPerformance)) - return suite +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestPerformance)) + return suite diff --git a/product/ERP5Type/tests/testSessionTool.py b/product/ERP5Type/tests/testSessionTool.py index a34dc7b17f..ac9d162b5f 100644 --- a/product/ERP5Type/tests/testSessionTool.py +++ b/product/ERP5Type/tests/testSessionTool.py @@ -26,20 +26,13 @@ # ############################################################################## -import os, sys -if __name__ == '__main__': - execfile(os.path.join(sys.path[0], 'framework.py')) - -# Needed in order to have a log file inside the current folder -os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log') -os.environ['EVENT_LOG_SEVERITY'] = '-300' +import unittest from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.Document import newTempOrder from AccessControl.SecurityManagement import newSecurityManager from zLOG import LOG -import time try: from transaction import get as get_transaction @@ -153,12 +146,8 @@ class TestSessionTool(ERP5TypeTestCase): session = portal_sessions[self.session_id] self.assert_(0 == len(session.keys())) -if __name__ == '__main__': - framework() -else: - import unittest - def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestSessionTool)) - return suite +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestSessionTool)) + return suite diff --git a/product/ERP5Type/tests/testTimerService.py b/product/ERP5Type/tests/testTimerService.py index d88a8a1d54..3174f7f11d 100644 --- a/product/ERP5Type/tests/testTimerService.py +++ b/product/ERP5Type/tests/testTimerService.py @@ -25,19 +25,13 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## -import os, sys -if __name__ == '__main__': - execfile(os.path.join(sys.path[0], 'framework.py')) -# Needed in order to have a log file inside the current folder -os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log') -os.environ['EVENT_LOG_SEVERITY'] = '-300' +import unittest from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from AccessControl.SecurityManagement import newSecurityManager, \ noSecurityManager from AccessControl.ZopeGuards import guarded_apply, guarded_getattr -# from Globals import guarded_getattr from zExceptions import Unauthorized class TestTimerService(ERP5TypeTestCase): @@ -96,11 +90,7 @@ class TestTimerService(ERP5TypeTestCase): # Do not care about any exception but unauthorized. pass -if __name__ == '__main__': - framework() -else: - import unittest - def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestTimerService)) - return suite +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestTimerService)) + return suite diff --git a/product/ERP5Type/tests/testTransactionalVariable.py b/product/ERP5Type/tests/testTransactionalVariable.py index 3b989d9e09..7a2c04be94 100644 --- a/product/ERP5Type/tests/testTransactionalVariable.py +++ b/product/ERP5Type/tests/testTransactionalVariable.py @@ -26,14 +26,7 @@ # ############################################################################## -import os -import sys -if __name__ == '__main__': - execfile(os.path.join(sys.path[0], 'framework.py')) - -# Needed in order to have a log file inside the current folder -os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log') -os.environ['EVENT_LOG_SEVERITY'] = '-300' +import unittest from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase @@ -156,11 +149,7 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor): self.failUnlessEqual(tv['toto'], 'titi') self.failUnlessEqual(getattr(portal, vattr, None), None) -if __name__ == '__main__': - framework() -else: - import unittest - def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestTransactionalVariable)) - return suite +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestTransactionalVariable)) + return suite diff --git a/product/ERP5Type/tests/testXMLMatrix.py b/product/ERP5Type/tests/testXMLMatrix.py index 7ad405e4d2..f0a8e5de52 100644 --- a/product/ERP5Type/tests/testXMLMatrix.py +++ b/product/ERP5Type/tests/testXMLMatrix.py @@ -27,21 +27,12 @@ # ############################################################################## -from random import randint - -import os, sys -if __name__ == '__main__': - execfile(os.path.join(sys.path[0], 'framework.py')) - -# Needed in order to have a log file inside the current folder -os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log') -os.environ['EVENT_LOG_SEVERITY'] = '-300' +import unittest from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase -from Products.ERP5.Document.DeliveryLine import DeliveryLine from Products.ERP5Type.Utils import cartesianProduct -from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager +from AccessControl.SecurityManagement import newSecurityManager from zLOG import LOG try: @@ -282,11 +273,7 @@ class TestXMLMatrix(ERP5TypeTestCase): ZopeTestCase._print('\nTest Set Cell Range And Catalog Without Activities ') self.checkSetCellRangeAndCatalog(active=0) -if __name__ == '__main__': - framework() -else: - import unittest - def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestXMLMatrix)) - return suite +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(TestXMLMatrix)) + return suite -- 2.30.9