Changeset 5e89ba in indico


Ignore:
Timestamp:
06/18/10 18:59:00 (3 years ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
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)
Message:

[FIX] Test Framework: Several fixes

  • Some more linting of indico.tests;
  • Small fixes;
  • Changed tests.conf.sample to fit latest changes;
  • Some more linting in fossilize and contextmanager;
Location:
indico
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/common/contextManager.py

    r58c67a r5e89ba  
    2626import threading 
    2727 
    28 class ContextManager: 
     28class 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 
    2936 
    3037    class NoContextException(Exception): 
     38        """ 
     39        Thrown where there is no Context currently defined 
     40        """ 
    3141        pass 
    3242 
    3343 
    3444    class DummyContext: 
     45        """ 
     46        A context that doesn't react, much like a Null Object 
     47        """ 
    3548 
    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            """ 
    3757            return None 
    3858 
     
    4666    @classmethod 
    4767    def _getContextDict(cls): 
     68        """ 
     69        Retrieve the corresponding dictionary for the current 
     70        context 
     71        """ 
    4872        if not hasattr(cls, 'contextDict'): 
    4973            cls.contextDict = {} 
     
    6993    @classmethod 
    7094    def destroy(cls): 
     95        """ 
     96        destroy the context 
     97        """ 
    7198        tid = threading._get_ident() 
    7299        del cls._getContextDict()[tid] 
     
    74101    @classmethod 
    75102    def create(cls): 
     103        """ 
     104        create the context 
     105        """ 
    76106        cls._getThreadContext(forceCleanup=True) 
    77107 
     
    112142    @classmethod 
    113143    def set(cls, name, value): 
     144        """ 
     145        Set the 'name' entry to 'value' 
     146        """ 
    114147        try: 
    115148            cls._getThreadContext()[name] = value 
  • indico/MaKaC/common/fossilize.py

    r58c67a r5e89ba  
    3232import re 
    3333import zope.interface 
    34 from types import NoneType, ClassType, TypeType 
     34from types import NoneType 
    3535 
    3636 
  • indico/tests/__init__.py

    r58c67a r5e89ba  
    2222# pylint: disable-msg=W0611 
    2323 
     24""" 
     25indico.tests provides a common framework for all the different libraries and 
     26technologies 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 
    2435# API classes 
    2536from indico.tests.config import TestConfig 
  • indico/tests/base.py

    r58c67a r5e89ba  
    2020## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 
    2121 
     22""" 
     23This module provides a skeleton of a test runner (BaseTestRunner) that all the 
     24other TestRunners should inherit from. 
     25""" 
     26 
    2227# System modules 
    2328import os, sys 
     
    4045 
    4146    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 
    4254        self.options = kwargs 
    4355        self.err = None 
    4456        self.out = None 
    4557 
     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 
    4666    def run(self): 
     67        """ 
     68        Executes the actual test code 
     69        """ 
    4770        # get the description from the first lines 
    4871        # of the docstring 
     
    5477 
    5578    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        """ 
    5684 
    5785        if self.options['verbose']: 
     
    6896 
    6997    def _finishIOCapture(self): 
     98        """ 
     99        Restore stdout/stderr and return the captured data 
     100        """ 
    70101        sys.stderr = sys.__stderr__ 
    71102        sys.stdout = sys.__stdout__ 
     
    76107    @staticmethod 
    77108    def _redirectPipeToStdout(pipe): 
     109        """ 
     110        Redirect a given pipe to stdout 
     111        """ 
    78112        while True: 
    79113            data = pipe.readline() 
     
    83117 
    84118    def writeReport(self, filename, content): 
     119        """ 
     120        Write the test report, using the filename and content that are passed 
     121        """ 
    85122        try: 
    86123            f = open(os.path.join(self.setupDir, 'report', filename + ".txt"), 'w') 
     
    94131    @staticmethod 
    95132    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        """ 
    97136 
    98137        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""" 
     23Here is defined a helper class that provides access to the configuration file 
     24for the testing framework. 
     25""" 
     26 
    127import os 
    228 
    329class TestConfig: 
     30    """ 
     31    Singleton Proxy for tests.conf, that loads it and provides get* methods 
     32    """ 
     33 
    434    __instance = None 
    535 
    636    def __init__(self): 
     37        """ 
     38        Initializes the proxy object, loading the configuration data 
     39        from tests.conf 
     40        """ 
    741        execfile(os.path.join(os.path.dirname(__file__), 'tests.conf')) 
    842        self.testsConf = locals() 
    943 
    1044    def __getattr__(self, attr): 
    11         """Dynamic finder for values defined in indico.conf 
     45        """ 
     46        Dynamic finder for values defined in indico.conf 
    1247 
    13             For example, if an indico.conf value is "username" this method will 
    14             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. 
    1550 
    16             If you add a new pair option = value to indico.conf there is no need to 
    17             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. 
    1853 
    19             This all means that changing the name of an indico.conf will force you 
    20             to change all references in code to getOldOptionName to getNewOptionName 
    21             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. 
    2257        """ 
     58 
    2359        # The following code intercepts all method calls that start with get and are 
    2460        # not already defined (so you can still override a get method if you want) 
     
    3369    @classmethod 
    3470    def getInstance(cls): 
     71        """ 
     72        Provides a single instance for this class (singleton) 
     73        """ 
    3574        if cls.__instance == None: 
    3675            cls.__instance = cls() 
  • indico/tests/core.py

    r58c67a r5e89ba  
    2020## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 
    2121 
     22# pylint: disable-msg=W0401 
     23 
     24""" 
     25This is the very core of indico.tests 
     26Here is defined the TestManager class, that provides a single point of access 
     27to the outside world. 
     28""" 
    2229 
    2330# System modules 
     
    5259 
    5360    def __init__(self): 
     61        """ 
     62        Initializes the object 
     63        """ 
    5464        self.dbmgr = None 
    5565        self.zeoServer = None 
     
    5868 
    5969    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        """ 
    6077 
    6178        returnString = "\n\n%s\n\n" % colored('** Results', 'blue', attrs = ['bold']) 
    6279 
    6380        #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) 
    6885 
    6986        if options['coverage']: 
     
    83100 
    84101 
    85         self.stopManageDB(fakeDBPolicy) 
     102        self._stopManageDB(fakeDBPolicy) 
     103 
     104        self._deleteTempFolders() 
    86105 
    87106        return returnString 
    88107 
    89     def configureTempFolders(self): 
     108    def _configureTempFolders(self): 
     109        """ 
     110        Creates temporary directories for the archive and uploaded files 
     111        """ 
     112 
    90113        keyNames = [#'LogDir', 
    91114                    'ArchiveDir', 
     
    97120        Config.getInstance().updateValues(self.tempDirs) 
    98121 
    99     def deleteTempFolders(self): 
     122    def _deleteTempFolders(self): 
     123        """ 
     124        Deletes the temporary folders 
     125        """ 
    100126        for k in self.tempDirs: 
    101127            shutil.rmtree(self.tempDirs[k]) 
    102128 
    103129################## 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 
    108136        with the production DB 
    109         fakeDBPolicy == 2, production DB is not running and functional tests 
     137        * fakeDBPolicy == 2, production DB is not running and functional tests 
    110138        need fake DB which is going to be run on production port. 
    111139        fakeDBPolicy == 3, production DB is running, we need to stop it and 
     
    114142 
    115143        if fakeDBPolicy == 1: 
    116             self.startFakeDB(TestConfig.getInstance().getFakeDBPort()) 
    117             TestManager.createDummyUser() 
     144            self._startFakeDB(TestConfig.getInstance().getFakeDBPort()) 
     145            TestManager._createDummyUser() 
    118146        elif fakeDBPolicy == 2: 
    119             self.startFakeDB(Config.getInstance().getDBConnectionParams()[1]) 
    120             TestManager.createDummyUser() 
     147            self._startFakeDB(Config.getInstance().getDBConnectionParams()[1]) 
     148            TestManager._createDummyUser() 
    121149        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        """ 
    127158        if fakeDBPolicy == 1 or fakeDBPolicy == 2: 
    128             self.stopFakeDB() 
    129             TestManager.restoreDBInstance() 
     159            self._stopFakeDB() 
     160            TestManager._restoreDBInstance() 
    130161        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( 
    138172            os.path.join(self.dbFolder, "Data.fs"), 
    139173            zeoPort) 
     
    141175        DBMgr.setInstance(DBMgr(hostname="localhost", port=zeoPort)) 
    142176 
    143     def stopFakeDB(self): 
     177    def _stopFakeDB(self): 
     178        """ 
     179        Stops the temporary DB 
     180        """ 
    144181        try: 
    145182            os.kill(self.zeoServer, signal.SIGINT) 
     
    149186        try: 
    150187            os.waitpid(self.zeoServer, 0) 
    151             self.removeDBFile() 
     188            self._removeDBFile() 
    152189        except OSError, e: 
    153190            print ("Problem waiting for ZEO Server: " + str(e)) 
    154191 
    155192    @staticmethod 
    156     def restoreDBInstance(): 
     193    def _restoreDBInstance(): 
     194        """ 
     195        Resets the DB instance in the DBMgr 
     196        """ 
    157197        DBMgr.setInstance(None) 
    158198 
    159199    @staticmethod 
    160     def startProductionDB(): 
     200    def _startProductionDB(): 
     201        """ 
     202        Starts the 'production' db (the one configured in indico.conf) 
     203        """ 
    161204        try: 
    162205            commands.getstatusoutput(TestConfig.getInstance().getStartDBCmd()) 
     
    166209 
    167210    @staticmethod 
    168     def stopProductionDB(): 
     211    def _stopProductionDB(): 
     212        """ 
     213        Stops the 'production' DB 
     214        """ 
    169215        try: 
    170216            commands.getstatusoutput(TestConfig.getInstance().getStopDBCmd()) 
     
    173219            sys.exit(1) 
    174220 
    175     def createNewDBFile(self): 
     221    def _createNewDBFile(self): 
     222        """ 
     223        Creates a new DB file for a temporary DB 
     224        """ 
    176225        from ZODB import FileStorage, DB 
    177226        savedDir = os.getcwd() 
     
    190239        os.chdir(savedDir) 
    191240 
    192     def removeDBFile(self): 
     241    def _removeDBFile(self): 
     242        """ 
     243        Removes the files of the temporary DB 
     244        """ 
    193245        shutil.rmtree(self.dbFolder) 
    194246 
    195247    @staticmethod 
    196     def createDBServer(dbFile, port): 
     248    def _createDBServer(dbFile, port): 
    197249        """ 
    198250        Creates a fake DB server for testing 
     
    211263 
    212264    @staticmethod 
    213     def createDummyUser(): 
     265    def _createDummyUser(): 
     266        """ 
     267        Creates a test user in the DB 
     268        """ 
    214269        from MaKaC import user 
    215270        from MaKaC.authentication import AuthenticatorMgr 
     
    247302 
    248303    @staticmethod 
    249     def deleteDummyUser(): 
     304    def _deleteDummyUser(): 
     305        """ 
     306        Deletes the test user from the DB 
     307        """ 
     308 
    250309        from MaKaC import user 
    251310        from MaKaC.authentication import AuthenticatorMgr 
  • indico/tests/env.py

    r28b84b r5e89ba  
    2020## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 
    2121 
     22# pylint: disable-msg=C0103,C0111 
     23 
    2224""" 
    2325This module contains a basic setup for unit tests that 
  • indico/tests/python/pylint/pylint.conf

    r58c67a r5e89ba  
    5454 
    5555# Disable the message(s) with the given id(s). 
    56 disable-msg=C0111, W0232, R0903, R0401, W0701, W0231, W0142 
     56disable=R0903,W0142 
    5757 
    5858 
     
    6161# Set the output format. Available formats are text, parseable, colorized, msvs 
    6262# (visual studio) and html 
    63 output-format=parseable 
     63output-format=colorized 
    6464 
    6565# Include message's id in output 
     
    8383# Add a comment according to your evaluation note. This is used by the global 
    8484# evaluation report (R0004). 
    85 comment=no 
     85comment=yes 
    8686 
    8787# Enable the report(s) with the given id(s). 
     
    268268# List of interface methods to ignore, separated by a comma. This is used for 
    269269# 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 
     270ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by,implements 
    271271 
    272272# List of method names used to declare (i.e. assign) instance attributes. 
  • indico/tests/runners.py

    r58c67a r5e89ba  
    2020## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 
    2121 
     22""" 
     23This 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 
    2236# System modules 
    2337import commands, os, signal, socket, subprocess, sys 
     
    91105 
    92106    def walkThroughPluginsFolders(self): 
     107        """ 
     108        Goes throught the plugin directories, and adds 
     109        existing unit test dirs 
     110        """ 
    93111        rootPluginsPath = os.path.join(self.setupDir, 
    94112                                       '..', 
     
    114132 
    115133    def start(self): 
     134        """ 
     135        starts figleaf 
     136        """ 
    116137        figleaf.start() 
    117138 
    118139    def stop(self): 
     140        """ 
     141        stops figleaf and returns a report 
     142        """ 
    119143        figleaf.stop() 
    120144        coverageOutput = figleaf.get_data().gather_files() 
    121145        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): 
    126149            os.mkdir(coverageDir) 
    127             figleaf.annotate_html.report_as_html(coverageOutput, 
    128                                                  coverageDir, [], {}) 
     150 
     151        figleaf.annotate_html.report_as_html(coverageOutput, 
     152                                             coverageDir, [], {}) 
    129153        return ("PY Coverage - Report generated in " 
    130154                             "tests/report/pycoverage/index.html\n") 
    131155 
    132156    def getInstance(cls): 
     157        """ 
     158        returns a singleton instance 
     159        """ 
    133160        if cls.__instance == None: 
    134161            return False 
     
    136163    getInstance = classmethod( getInstance ) 
    137164 
     165    @classmethod 
    138166    def instantiate(cls): 
     167        """ 
     168        create an instance of the class (singleton) 
     169        """ 
    139170        cls.__instance = CoverageTestRunner() 
    140     instantiate = classmethod( instantiate ) 
    141171 
    142172 
     
    191221 
    192222    def walkThroughPluginsFolders(self): 
     223        """ 
     224        Goes throught the plugin directories, and adds 
     225        existing functional test dirs 
     226        """ 
    193227        rootPluginsPath = os.path.join(self.setupDir, '..', 'MaKaC', 'plugins') 
    194228        foldersArray = [] 
     
    201235 
    202236    def startSeleniumServer(self): 
     237        """ 
     238        starts the selenium server 
     239        """ 
    203240        started = True 
    204241        try: 
     
    235272 
    236273    def stopSeleniumServer(self): 
     274        """ 
     275        stops the selenium server 
     276        """ 
    237277        self.child.kill() 
    238278 
     
    243283    """ 
    244284 
    245     def __init__(self, specifyArg): 
     285    def __init__(self, specifyArg, **kwargs): 
     286        FunctionalTestRunner.__init__(self) 
    246287        self.specify = specifyArg 
    247288 
     
    364405 
    365406    def isActive(self): 
     407        """ 
     408        returns True if the grid is active, False otherwise 
     409        """ 
    366410        return self.active 
     411 
    367412    def getUrl(self): 
     413        """ 
     414        returns the hub URL 
     415        """ 
    368416        return self.url 
     417 
    369418    def getPort(self): 
     419        """ 
     420        returns the hub port 
     421        """ 
    370422        return self.port 
     423 
    371424    def getEnv(self): 
     425        """ 
     426        returns the current running environment 
     427        """ 
    372428        return self.currentEnv 
    373429 
    374430    def setActive(self, active): 
     431        """ 
     432        sets the active status for the grid 
     433        """ 
    375434        self.active = active 
     435 
    376436    def setUrl(self, url): 
     437        """ 
     438        sets the hub url 
     439        """ 
    377440        self.url = url 
     441 
    378442    def setPort(self, port): 
     443        """ 
     444        sets the hub port 
     445        """ 
    379446        self.port = port 
     447 
    380448    def setEnv(self, env): 
     449        """ 
     450        sets the current running environment 
     451        """ 
    381452        self.currentEnv = env 
    382453 
    383454    @classmethod 
    384455    def getInstance(cls): 
     456        """ 
     457        gets a class instance (singleton) 
     458        """ 
    385459        if cls.__instance == None: 
    386460            cls.__instance = GridDataTestRunner() 
     
    396470        returnString = "" 
    397471 
     472        import pylint.lint 
     473 
     474        fileList = TestConfig.getInstance().getPylintFiles() 
     475 
    398476        self._startIOCapture() 
    399477 
    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  
    407478        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 
    418486        except OSError, e: 
    419487            self._finishIOCapture() 
     
    568636 
    569637    def buildConfFile(self, confFilePath, coverage): 
     638        """ 
     639        Builds a jslint config file 
     640        """ 
    570641        confTemplatePath = os.path.join(self.setupDir, 
    571642                                        'javascript', 
     
    690761 
    691762    def runJSLint(self, path, folderRestriction=''): 
     763        """ 
     764        runs the actual JSLint command 
     765        """ 
    692766        returnString = "" 
    693767        for root, __, files in os.walk(os.path.join(self.setupDir, 
     
    714788 
    715789def raiseTimeout(__, ___): 
     790    """ 
     791    handler for the timeout signal 
     792    """ 
    716793    raise TimeoutException("15sec Timeout") 
  • indico/tests/tests.conf.sample

    r28b84b r5e89ba  
    2525PylintFiles        =   ["MaKaC.common.contextManager", 
    2626                        "MaKaC.common.fossilize", 
    27                         "tests.runners", 
    28                         "tests.__init__", 
    29                         "tests.core", 
    30                         "tests.config", 
    31                         "tests.base"] 
    32  
     27                        "indico.tests"] 
    3328 
    3429JSUnitURL          = "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""" 
     23Modifies the location of indico.conf referenced inside makacconfigpy_path to 
     24point to indico_conf_path 
     25""" 
    326import os 
    427import re 
    528fdata = 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) 
     29fdata = re.sub('indico_conf[ ]*=[ ]*[\'"]{1}([^\'"]*)[\'"]{1}', 
     30               "indico_conf = \"%s\"" % os.path.join('etc', 'indico.conf'), fdata) 
    731open(os.path.join('indico', 'MaKaC', 'common', 'MaKaCConfig.py'), 'w').write(fdata) 
  • indico/tests/util.py

    r58c67a r5e89ba  
    2020## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 
    2121 
     22""" 
     23This module defines some utility classes for the testing framework, 
     24such as a wrapper for ZEOServer that allows a "test" server to be created 
     25""" 
    2226 
    2327import os 
     
    2630from ZEO.runzeo import ZEOOptions, ZEOServer 
    2731 
     32 
    2833class TestZEOServer: 
    29  
     34    """ 
     35    Creates a standalone ZEO server for tests 
     36    """ 
    3037    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]) 
    3340        self.server = ZEOServer(self.options) 
    3441 
    3542    def start(self): 
     43        """ 
     44        Actually starts the server 
     45        """ 
    3646        print "spawning server on PID %s" % os.getpid() 
    3747        self.server.main() 
    3848 
     49 
    3950class 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) 
    4057 
    41      def __init__(self, out): 
    42          self.__outStream =  out 
    43          StringIO.__init__(self) 
     58    def write(self, string): 
     59        self.__outStream.write(string) 
     60        StringIO.write(self, string) 
    4461 
    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)) 
    4865 
    49      def read(self): 
    50          self.seek(0) 
    51          self.__outStream.write(StringIO.read(self)) 
    52  
     66# pylint: disable-msg=W0611 
    5367 
    5468try: 
    5569    from termcolor import colored 
    56 except: 
     70except ImportError: 
    5771    def colored(text, *__, **___): 
     72        """ 
     73        just a dummy function that returns the same string 
     74        (in case termcolor is not available) 
     75        """ 
    5876        return text 
Note: See TracChangeset for help on using the changeset viewer.