Changeset 5e89ba in indico
- Timestamp:
- 06/18/10 18:59:00 (3 years ago)
- Branches:
- master, burotel, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
- Children:
- 72801b
- Parents:
- 58c67a
- git-author:
- Pedro Ferreira <jose.pedro.ferreira@…> (05/07/10 14:32:59)
- git-committer:
- Pedro Ferreira <jose.pedro.ferreira@…> (06/18/10 18:59:00)
- Location:
- indico
- Files:
-
- 12 edited
-
MaKaC/common/contextManager.py (modified) (5 diffs)
-
MaKaC/common/fossilize.py (modified) (1 diff)
-
tests/__init__.py (modified) (1 diff)
-
tests/base.py (modified) (7 diffs)
-
tests/config.py (modified) (2 diffs)
-
tests/core.py (modified) (13 diffs)
-
tests/env.py (modified) (1 diff)
-
tests/python/pylint/pylint.conf (modified) (4 diffs)
-
tests/runners.py (modified) (13 diffs)
-
tests/tests.conf.sample (modified) (1 diff)
-
tests/updateConf.py (modified) (1 diff)
-
tests/util.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/common/contextManager.py
r58c67a r5e89ba 26 26 import threading 27 27 28 class ContextManager: 28 class ContextManager(object): 29 """ 30 A context manager provides a global access namespace (singleton) for storing 31 run-time information. 32 """ 33 34 def __init__(self): 35 pass 29 36 30 37 class NoContextException(Exception): 38 """ 39 Thrown where there is no Context currently defined 40 """ 31 41 pass 32 42 33 43 34 44 class DummyContext: 45 """ 46 A context that doesn't react, much like a Null Object 47 """ 35 48 36 def _dummyMethod(*args, **kwargs): 49 def __init__(self): 50 pass 51 52 def _dummyMethod(*args, **__): 53 """ 54 this method just does nothing, accepting 55 whatever arguments are passed to it 56 """ 37 57 return None 38 58 … … 46 66 @classmethod 47 67 def _getContextDict(cls): 68 """ 69 Retrieve the corresponding dictionary for the current 70 context 71 """ 48 72 if not hasattr(cls, 'contextDict'): 49 73 cls.contextDict = {} … … 69 93 @classmethod 70 94 def destroy(cls): 95 """ 96 destroy the context 97 """ 71 98 tid = threading._get_ident() 72 99 del cls._getContextDict()[tid] … … 74 101 @classmethod 75 102 def create(cls): 103 """ 104 create the context 105 """ 76 106 cls._getThreadContext(forceCleanup=True) 77 107 … … 112 142 @classmethod 113 143 def set(cls, name, value): 144 """ 145 Set the 'name' entry to 'value' 146 """ 114 147 try: 115 148 cls._getThreadContext()[name] = value -
indico/MaKaC/common/fossilize.py
r58c67a r5e89ba 32 32 import re 33 33 import zope.interface 34 from types import NoneType , ClassType, TypeType34 from types import NoneType 35 35 36 36 -
indico/tests/__init__.py
r58c67a r5e89ba 22 22 # pylint: disable-msg=W0611 23 23 24 """ 25 indico.tests provides a common framework for all the different libraries and 26 technologies used for different types of testing. 27 28 * Python/JS Unit Tests - using nosetest and JSUnit 29 * Python Coverage Tests - using figleaf 30 * Functional Tests - using selenium and selenium grid 31 * Code conventions, standards, smells - Pylint and JSlint 32 33 """ 34 24 35 # API classes 25 36 from indico.tests.config import TestConfig -
indico/tests/base.py
r58c67a r5e89ba 20 20 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 21 21 22 """ 23 This module provides a skeleton of a test runner (BaseTestRunner) that all the 24 other TestRunners should inherit from. 25 """ 26 22 27 # System modules 23 28 import os, sys … … 40 45 41 46 def __init__(self, **kwargs): 47 """ 48 Options can be passed as kwargs, currently the following is supported: 49 50 * verbose - if the output should be redirected to the console in 51 addition to the log file; 52 """ 53 42 54 self.options = kwargs 43 55 self.err = None 44 56 self.out = None 45 57 58 def _run(self): 59 """ 60 This method should be overloaded by inheriting classes. 61 It should provide the code that executes the actual tests, 62 returning output information. 63 """ 64 pass 65 46 66 def run(self): 67 """ 68 Executes the actual test code 69 """ 47 70 # get the description from the first lines 48 71 # of the docstring … … 54 77 55 78 def _startIOCapture(self): 79 """ 80 Start capturing stdout and stderr to StringIOs 81 If options['verbose'] has been set, the data will be output to the 82 stdout/stderr as well 83 """ 56 84 57 85 if self.options['verbose']: … … 68 96 69 97 def _finishIOCapture(self): 98 """ 99 Restore stdout/stderr and return the captured data 100 """ 70 101 sys.stderr = sys.__stderr__ 71 102 sys.stdout = sys.__stdout__ … … 76 107 @staticmethod 77 108 def _redirectPipeToStdout(pipe): 109 """ 110 Redirect a given pipe to stdout 111 """ 78 112 while True: 79 113 data = pipe.readline() … … 83 117 84 118 def writeReport(self, filename, content): 119 """ 120 Write the test report, using the filename and content that are passed 121 """ 85 122 try: 86 123 f = open(os.path.join(self.setupDir, 'report', filename + ".txt"), 'w') … … 94 131 @staticmethod 95 132 def walkThroughFolders(rootPath, foldersPattern): 96 """scan a directory and return folders which match the pattern""" 133 """ 134 Scan a directory and return folders which match the pattern 135 """ 97 136 98 137 rootPluginsPath = os.path.join(rootPath) -
indico/tests/config.py
r28b84b r5e89ba 1 # -*- coding: utf-8 -*- 2 ## 3 ## $Id$ 4 ## 5 ## This file is part of CDS Indico. 6 ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN. 7 ## 8 ## CDS Indico is free software; you can redistribute it and/or 9 ## modify it under the terms of the GNU General Public License as 10 ## published by the Free Software Foundation; either version 2 of the 11 ## License, or (at your option) any later version. 12 ## 13 ## CDS Indico is distributed in the hope that it will be useful, but 14 ## WITHOUT ANY WARRANTY; without even the implied warranty of 15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 ## General Public License for more details. 17 ## 18 ## You should have received a copy of the GNU General Public License 19 ## along with CDS Indico; if not, write to the Free Software Foundation, Inc., 20 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 21 22 """ 23 Here is defined a helper class that provides access to the configuration file 24 for the testing framework. 25 """ 26 1 27 import os 2 28 3 29 class TestConfig: 30 """ 31 Singleton Proxy for tests.conf, that loads it and provides get* methods 32 """ 33 4 34 __instance = None 5 35 6 36 def __init__(self): 37 """ 38 Initializes the proxy object, loading the configuration data 39 from tests.conf 40 """ 7 41 execfile(os.path.join(os.path.dirname(__file__), 'tests.conf')) 8 42 self.testsConf = locals() 9 43 10 44 def __getattr__(self, attr): 11 """Dynamic finder for values defined in indico.conf 45 """ 46 Dynamic finder for values defined in indico.conf 12 47 13 For example, if an indico.conf value is "username" this method will14 return its value for a getUsername() call.48 For example, if an indico.conf value is "username" this method will 49 return its value for a getUsername() call. 15 50 16 If you add a new pair option = value to indico.conf there is no need to17 create anything here. It will be returned automatically.51 If you add a new pair option = value to indico.conf there is no need to 52 create anything here. It will be returned automatically. 18 53 19 This all means that changing the name of an indico.conf will force you20 to change all references in code to getOldOptionName to getNewOptionName21 including the reference in default_values in this file.54 This all means that changing the name of an indico.conf will force you 55 to change all references in code to getOldOptionName to getNewOptionName 56 including the reference in default_values in this file. 22 57 """ 58 23 59 # The following code intercepts all method calls that start with get and are 24 60 # not already defined (so you can still override a get method if you want) … … 33 69 @classmethod 34 70 def getInstance(cls): 71 """ 72 Provides a single instance for this class (singleton) 73 """ 35 74 if cls.__instance == None: 36 75 cls.__instance = cls() -
indico/tests/core.py
r58c67a r5e89ba 20 20 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 21 21 22 # pylint: disable-msg=W0401 23 24 """ 25 This is the very core of indico.tests 26 Here is defined the TestManager class, that provides a single point of access 27 to the outside world. 28 """ 22 29 23 30 # System modules … … 52 59 53 60 def __init__(self): 61 """ 62 Initializes the object 63 """ 54 64 self.dbmgr = None 55 65 self.zeoServer = None … … 58 68 59 69 def main(self, fakeDBPolicy, testsToRun, options): 70 """ 71 Runs the main test cycle, iterating over all the TestRunners available 72 73 * fakeDBPolicy - see startManageDB() 74 * testsToRun - a list of strings specifying which tests to run 75 * options - test options (such as verbosity...) 76 """ 60 77 61 78 returnString = "\n\n%s\n\n" % colored('** Results', 'blue', attrs = ['bold']) 62 79 63 80 #To not pollute the installation of Indico 64 self. configureTempFolders()65 66 67 self. startManageDB(fakeDBPolicy)81 self._configureTempFolders() 82 83 84 self._startManageDB(fakeDBPolicy) 68 85 69 86 if options['coverage']: … … 83 100 84 101 85 self.stopManageDB(fakeDBPolicy) 102 self._stopManageDB(fakeDBPolicy) 103 104 self._deleteTempFolders() 86 105 87 106 return returnString 88 107 89 def configureTempFolders(self): 108 def _configureTempFolders(self): 109 """ 110 Creates temporary directories for the archive and uploaded files 111 """ 112 90 113 keyNames = [#'LogDir', 91 114 'ArchiveDir', … … 97 120 Config.getInstance().updateValues(self.tempDirs) 98 121 99 def deleteTempFolders(self): 122 def _deleteTempFolders(self): 123 """ 124 Deletes the temporary folders 125 """ 100 126 for k in self.tempDirs: 101 127 shutil.rmtree(self.tempDirs[k]) 102 128 103 129 ################## Start of DB Managing functions ################## 104 def startManageDB(self, fakeDBPolicy): 105 """ 106 fakeDBPolicy == 0, the tests to run do not need any DB 107 fakeDBPolicy == 1, unit tests need a fake DB that can be run in parallel 130 def _startManageDB(self, fakeDBPolicy): 131 """ 132 Stops the production DB (if needed) and starts a temporary / fake DB 133 134 * fakeDBPolicy == 0, the tests to run do not need any DB 135 * fakeDBPolicy == 1, unit tests need a fake DB that can be run in parallel 108 136 with the production DB 109 fakeDBPolicy == 2, production DB is not running and functional tests137 * fakeDBPolicy == 2, production DB is not running and functional tests 110 138 need fake DB which is going to be run on production port. 111 139 fakeDBPolicy == 3, production DB is running, we need to stop it and … … 114 142 115 143 if fakeDBPolicy == 1: 116 self. startFakeDB(TestConfig.getInstance().getFakeDBPort())117 TestManager. createDummyUser()144 self._startFakeDB(TestConfig.getInstance().getFakeDBPort()) 145 TestManager._createDummyUser() 118 146 elif fakeDBPolicy == 2: 119 self. startFakeDB(Config.getInstance().getDBConnectionParams()[1])120 TestManager. createDummyUser()147 self._startFakeDB(Config.getInstance().getDBConnectionParams()[1]) 148 TestManager._createDummyUser() 121 149 elif fakeDBPolicy == 3: 122 TestManager.stopProductionDB() 123 self.startFakeDB(Config.getInstance().getDBConnectionParams()[1]) 124 TestManager.createDummyUser() 125 126 def stopManageDB(self, fakeDBPolicy): 150 TestManager._stopProductionDB() 151 self._startFakeDB(Config.getInstance().getDBConnectionParams()[1]) 152 TestManager._createDummyUser() 153 154 def _stopManageDB(self, fakeDBPolicy): 155 """ 156 Stops the temporary DB and restarts the production DB if needed 157 """ 127 158 if fakeDBPolicy == 1 or fakeDBPolicy == 2: 128 self. stopFakeDB()129 TestManager. restoreDBInstance()159 self._stopFakeDB() 160 TestManager._restoreDBInstance() 130 161 elif fakeDBPolicy == 3: 131 self.stopFakeDB() 132 TestManager.startProductionDB() 133 TestManager.restoreDBInstance() 134 135 def startFakeDB(self, zeoPort): 136 self.createNewDBFile() 137 self.zeoServer = TestManager.createDBServer( 162 self._stopFakeDB() 163 TestManager._startProductionDB() 164 TestManager._restoreDBInstance() 165 166 def _startFakeDB(self, zeoPort): 167 """ 168 Starts a temporary DB in a different port 169 """ 170 self._createNewDBFile() 171 self.zeoServer = TestManager._createDBServer( 138 172 os.path.join(self.dbFolder, "Data.fs"), 139 173 zeoPort) … … 141 175 DBMgr.setInstance(DBMgr(hostname="localhost", port=zeoPort)) 142 176 143 def stopFakeDB(self): 177 def _stopFakeDB(self): 178 """ 179 Stops the temporary DB 180 """ 144 181 try: 145 182 os.kill(self.zeoServer, signal.SIGINT) … … 149 186 try: 150 187 os.waitpid(self.zeoServer, 0) 151 self. removeDBFile()188 self._removeDBFile() 152 189 except OSError, e: 153 190 print ("Problem waiting for ZEO Server: " + str(e)) 154 191 155 192 @staticmethod 156 def restoreDBInstance(): 193 def _restoreDBInstance(): 194 """ 195 Resets the DB instance in the DBMgr 196 """ 157 197 DBMgr.setInstance(None) 158 198 159 199 @staticmethod 160 def startProductionDB(): 200 def _startProductionDB(): 201 """ 202 Starts the 'production' db (the one configured in indico.conf) 203 """ 161 204 try: 162 205 commands.getstatusoutput(TestConfig.getInstance().getStartDBCmd()) … … 166 209 167 210 @staticmethod 168 def stopProductionDB(): 211 def _stopProductionDB(): 212 """ 213 Stops the 'production' DB 214 """ 169 215 try: 170 216 commands.getstatusoutput(TestConfig.getInstance().getStopDBCmd()) … … 173 219 sys.exit(1) 174 220 175 def createNewDBFile(self): 221 def _createNewDBFile(self): 222 """ 223 Creates a new DB file for a temporary DB 224 """ 176 225 from ZODB import FileStorage, DB 177 226 savedDir = os.getcwd() … … 190 239 os.chdir(savedDir) 191 240 192 def removeDBFile(self): 241 def _removeDBFile(self): 242 """ 243 Removes the files of the temporary DB 244 """ 193 245 shutil.rmtree(self.dbFolder) 194 246 195 247 @staticmethod 196 def createDBServer(dbFile, port):248 def _createDBServer(dbFile, port): 197 249 """ 198 250 Creates a fake DB server for testing … … 211 263 212 264 @staticmethod 213 def createDummyUser(): 265 def _createDummyUser(): 266 """ 267 Creates a test user in the DB 268 """ 214 269 from MaKaC import user 215 270 from MaKaC.authentication import AuthenticatorMgr … … 247 302 248 303 @staticmethod 249 def deleteDummyUser(): 304 def _deleteDummyUser(): 305 """ 306 Deletes the test user from the DB 307 """ 308 250 309 from MaKaC import user 251 310 from MaKaC.authentication import AuthenticatorMgr -
indico/tests/env.py
r28b84b r5e89ba 20 20 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 21 21 22 # pylint: disable-msg=C0103,C0111 23 22 24 """ 23 25 This module contains a basic setup for unit tests that -
indico/tests/python/pylint/pylint.conf
r58c67a r5e89ba 54 54 55 55 # Disable the message(s) with the given id(s). 56 disable -msg=C0111, W0232, R0903, R0401, W0701, W0231,W014256 disable=R0903,W0142 57 57 58 58 … … 61 61 # Set the output format. Available formats are text, parseable, colorized, msvs 62 62 # (visual studio) and html 63 output-format= parseable63 output-format=colorized 64 64 65 65 # Include message's id in output … … 83 83 # Add a comment according to your evaluation note. This is used by the global 84 84 # evaluation report (R0004). 85 comment= no85 comment=yes 86 86 87 87 # Enable the report(s) with the given id(s). … … 268 268 # List of interface methods to ignore, separated by a comma. This is used for 269 269 # instance to not check methods defines in Zope's Interface base class. 270 ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by 270 ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by,implements 271 271 272 272 # List of method names used to declare (i.e. assign) instance attributes. -
indico/tests/runners.py
r58c67a r5e89ba 20 20 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 21 21 22 """ 23 This module defines the TestRunners that are included by default by indico.tests: 24 25 * UnitTestRunner 26 * CoverageTestRunner 27 * FunctionalTestRunner 28 * SpecificFunctionalTestRunner 29 * GridTestRunner 30 * PylintTestRunner 31 * JSLintTestRunner 32 * JSUnitTestRunner 33 34 """ 35 22 36 # System modules 23 37 import commands, os, signal, socket, subprocess, sys … … 91 105 92 106 def walkThroughPluginsFolders(self): 107 """ 108 Goes throught the plugin directories, and adds 109 existing unit test dirs 110 """ 93 111 rootPluginsPath = os.path.join(self.setupDir, 94 112 '..', … … 114 132 115 133 def start(self): 134 """ 135 starts figleaf 136 """ 116 137 figleaf.start() 117 138 118 139 def stop(self): 140 """ 141 stops figleaf and returns a report 142 """ 119 143 figleaf.stop() 120 144 coverageOutput = figleaf.get_data().gather_files() 121 145 coverageDir = os.path.join(self.setupDir, 'report', 'pycoverage') 122 try: 123 figleaf.annotate_html.report_as_html(coverageOutput, 124 coverageDir, [], {}) 125 except IOError: 146 147 # check if there's a dir first 148 if not os.path.exists(coverageDir): 126 149 os.mkdir(coverageDir) 127 figleaf.annotate_html.report_as_html(coverageOutput, 128 coverageDir, [], {}) 150 151 figleaf.annotate_html.report_as_html(coverageOutput, 152 coverageDir, [], {}) 129 153 return ("PY Coverage - Report generated in " 130 154 "tests/report/pycoverage/index.html\n") 131 155 132 156 def getInstance(cls): 157 """ 158 returns a singleton instance 159 """ 133 160 if cls.__instance == None: 134 161 return False … … 136 163 getInstance = classmethod( getInstance ) 137 164 165 @classmethod 138 166 def instantiate(cls): 167 """ 168 create an instance of the class (singleton) 169 """ 139 170 cls.__instance = CoverageTestRunner() 140 instantiate = classmethod( instantiate )141 171 142 172 … … 191 221 192 222 def walkThroughPluginsFolders(self): 223 """ 224 Goes throught the plugin directories, and adds 225 existing functional test dirs 226 """ 193 227 rootPluginsPath = os.path.join(self.setupDir, '..', 'MaKaC', 'plugins') 194 228 foldersArray = [] … … 201 235 202 236 def startSeleniumServer(self): 237 """ 238 starts the selenium server 239 """ 203 240 started = True 204 241 try: … … 235 272 236 273 def stopSeleniumServer(self): 274 """ 275 stops the selenium server 276 """ 237 277 self.child.kill() 238 278 … … 243 283 """ 244 284 245 def __init__(self, specifyArg): 285 def __init__(self, specifyArg, **kwargs): 286 FunctionalTestRunner.__init__(self) 246 287 self.specify = specifyArg 247 288 … … 364 405 365 406 def isActive(self): 407 """ 408 returns True if the grid is active, False otherwise 409 """ 366 410 return self.active 411 367 412 def getUrl(self): 413 """ 414 returns the hub URL 415 """ 368 416 return self.url 417 369 418 def getPort(self): 419 """ 420 returns the hub port 421 """ 370 422 return self.port 423 371 424 def getEnv(self): 425 """ 426 returns the current running environment 427 """ 372 428 return self.currentEnv 373 429 374 430 def setActive(self, active): 431 """ 432 sets the active status for the grid 433 """ 375 434 self.active = active 435 376 436 def setUrl(self, url): 437 """ 438 sets the hub url 439 """ 377 440 self.url = url 441 378 442 def setPort(self, port): 443 """ 444 sets the hub port 445 """ 379 446 self.port = port 447 380 448 def setEnv(self, env): 449 """ 450 sets the current running environment 451 """ 381 452 self.currentEnv = env 382 453 383 454 @classmethod 384 455 def getInstance(cls): 456 """ 457 gets a class instance (singleton) 458 """ 385 459 if cls.__instance == None: 386 460 cls.__instance = GridDataTestRunner() … … 396 470 returnString = "" 397 471 472 import pylint.lint 473 474 fileList = TestConfig.getInstance().getPylintFiles() 475 398 476 self._startIOCapture() 399 477 400 baseDir = os.path.join(self.setupDir, '..')401 402 filePaths = map(lambda s: s.replace('.', os.sep)+".py",403 TestConfig.getInstance().getPylintFiles())404 405 fileList = list(os.path.join(baseDir, f) for f in filePaths)406 407 478 try: 408 pylintProcess = subprocess.Popen( 409 ["pylint", "--rcfile=%s" % os.path.join(self.setupDir, 410 'python', 411 'pylint', 412 'pylint.conf'), 413 ] + fileList, 414 stdout = subprocess.PIPE, 415 stderr = subprocess.STDOUT) 416 417 self._redirectPipeToStdout(pylintProcess.stdout) 479 pylint.lint.Run( 480 ["--rcfile=%s" % os.path.join(self.setupDir, 481 'python', 482 'pylint', 483 'pylint.conf'), 484 ] + fileList) 485 418 486 except OSError, e: 419 487 self._finishIOCapture() … … 568 636 569 637 def buildConfFile(self, confFilePath, coverage): 638 """ 639 Builds a jslint config file 640 """ 570 641 confTemplatePath = os.path.join(self.setupDir, 571 642 'javascript', … … 690 761 691 762 def runJSLint(self, path, folderRestriction=''): 763 """ 764 runs the actual JSLint command 765 """ 692 766 returnString = "" 693 767 for root, __, files in os.walk(os.path.join(self.setupDir, … … 714 788 715 789 def raiseTimeout(__, ___): 790 """ 791 handler for the timeout signal 792 """ 716 793 raise TimeoutException("15sec Timeout") -
indico/tests/tests.conf.sample
r28b84b r5e89ba 25 25 PylintFiles = ["MaKaC.common.contextManager", 26 26 "MaKaC.common.fossilize", 27 "tests.runners", 28 "tests.__init__", 29 "tests.core", 30 "tests.config", 31 "tests.base"] 32 27 "indico.tests"] 33 28 34 29 JSUnitURL = "http://js-test-driver.googlecode.com/files/JsTestDriver-1.2.jar" -
indico/tests/updateConf.py
rce5cca r5e89ba 1 '''Modifies the location of indico.conf referenced inside makacconfigpy_path to 2 point to indico_conf_path''' 1 # -*- coding: utf-8 -*- 2 ## 3 ## $Id$ 4 ## 5 ## This file is part of CDS Indico. 6 ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN. 7 ## 8 ## CDS Indico is free software; you can redistribute it and/or 9 ## modify it under the terms of the GNU General Public License as 10 ## published by the Free Software Foundation; either version 2 of the 11 ## License, or (at your option) any later version. 12 ## 13 ## CDS Indico is distributed in the hope that it will be useful, but 14 ## WITHOUT ANY WARRANTY; without even the implied warranty of 15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 ## General Public License for more details. 17 ## 18 ## You should have received a copy of the GNU General Public License 19 ## along with CDS Indico; if not, write to the Free Software Foundation, Inc., 20 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 21 22 """ 23 Modifies the location of indico.conf referenced inside makacconfigpy_path to 24 point to indico_conf_path 25 """ 3 26 import os 4 27 import re 5 28 fdata = open(os.path.join('indico', 'MaKaC', 'common', 'MaKaCConfig.py')).read() 6 fdata = re.sub('indico_conf[ ]*=[ ]*[\'"]{1}([^\'"]*)[\'"]{1}', "indico_conf = \"%s\"" % os.path.join('etc', 'indico.conf'), fdata) 29 fdata = re.sub('indico_conf[ ]*=[ ]*[\'"]{1}([^\'"]*)[\'"]{1}', 30 "indico_conf = \"%s\"" % os.path.join('etc', 'indico.conf'), fdata) 7 31 open(os.path.join('indico', 'MaKaC', 'common', 'MaKaCConfig.py'), 'w').write(fdata) -
indico/tests/util.py
r58c67a r5e89ba 20 20 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 21 21 22 """ 23 This module defines some utility classes for the testing framework, 24 such as a wrapper for ZEOServer that allows a "test" server to be created 25 """ 22 26 23 27 import os … … 26 30 from ZEO.runzeo import ZEOOptions, ZEOServer 27 31 32 28 33 class TestZEOServer: 29 34 """ 35 Creates a standalone ZEO server for tests 36 """ 30 37 def __init__(self, port, fd): 31 self.options = ZEOOptions() ;32 self.options.realize(['-f', fd,'-a','localhost:%d' % port])38 self.options = ZEOOptions() 39 self.options.realize(['-f', fd, '-a', 'localhost:%d' % port]) 33 40 self.server = ZEOServer(self.options) 34 41 35 42 def start(self): 43 """ 44 Actually starts the server 45 """ 36 46 print "spawning server on PID %s" % os.getpid() 37 47 self.server.main() 38 48 49 39 50 class TeeStringIO(StringIO): 51 """ 52 Wrapper for StringIO that writes to an output stream as well 53 """ 54 def __init__(self, out): 55 self.__outStream = out 56 StringIO.__init__(self) 40 57 41 def __init__(self, out):42 self.__outStream = out43 StringIO.__init__(self)58 def write(self, string): 59 self.__outStream.write(string) 60 StringIO.write(self, string) 44 61 45 def write(self, string):46 self.__outStream.write(string)47 StringIO.write(self, string)62 def read(self, n=-1): 63 self.seek(0) 64 self.__outStream.write(StringIO.read(self, n=n)) 48 65 49 def read(self): 50 self.seek(0) 51 self.__outStream.write(StringIO.read(self)) 52 66 # pylint: disable-msg=W0611 53 67 54 68 try: 55 69 from termcolor import colored 56 except :70 except ImportError: 57 71 def colored(text, *__, **___): 72 """ 73 just a dummy function that returns the same string 74 (in case termcolor is not available) 75 """ 58 76 return text
Note: See TracChangeset
for help on using the changeset viewer.
