Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1135

Show
Ignore:
Timestamp:
06/11/06 23:11:53
Author:
fumanchu
Message:

Moved coverage out of the core.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/__init__.py

    r1134 r1135  
    2222    server.start() 
    2323    engine.start() 
    24  
    25 codecoverage = False 
    2624 
    2725try: 
  • trunk/cherrypy/_cpengine.py

    r1133 r1135  
    4343        if conf("log_config_options", True): 
    4444            cherrypy.config.output_config_map() 
    45          
    46         if cherrypy.codecoverage: 
    47             from cherrypy.lib import covercp 
    48             covercp.start() 
    4945         
    5046        # Autoreload. Note that, if we're not starting our own HTTP server, 
     
    150146            threadID = threading._get_ident() 
    151147            if threadID not in self.seen_threads: 
    152                  
    153                 if cherrypy.codecoverage: 
    154                     from cherrypy.lib import covercp 
    155                     covercp.start() 
    156                  
    157148                i = len(self.seen_threads) + 1 
    158149                self.seen_threads[threadID] = i 
  • trunk/cherrypy/lib/covercp.py

    r1095 r1135  
    99http://www.nedbatchelder.com/code/modules/coverage.html 
    1010 
    11 Set "cherrypy.codecoverage = True" to turn on coverage tracing. 
    12 Then, use the serve() function to browse the results in a web browser. 
    13 If you run this module from the command line, it will call serve() for you. 
     11To turn on coverage tracing, use the following code: 
     12 
     13    cherrypy.engine.on_start_engine_list.insert(0, covercp.start) 
     14    cherrypy.engine.on_start_thread_list.insert(0, covercp.start) 
     15 
     16Run your code, then use the covercp.serve() function to browse the 
     17results in a web browser. If you run this module from the command line, 
     18it will call serve() for you. 
    1419""" 
    1520 
     
    2833try: 
    2934    from coverage import the_coverage as coverage 
    30     def start(): 
     35    def start(threadid=None): 
    3136        coverage.start() 
    3237except ImportError: 
     
    3843    warnings.warn("No code coverage will be performed; coverage.py could not be imported.") 
    3944     
    40     def start(): 
     45    def start(threadid=None): 
    4146        pass 
    4247 
  • trunk/cherrypy/test/test.py

    r1117 r1135  
    174174        http://www.nedbatchelder.com/code/modules/coverage.html 
    175175         
    176         If neither module is found in PYTHONPATH, coverage is disabled. 
     176        If neither module is found in PYTHONPATH, 
     177        coverage is silently(!) disabled. 
    177178        """ 
    178179        try: 
     
    184185            coverage.start() 
    185186            import cherrypy 
    186             cherrypy.codecoverage = True 
     187            from cherrypy.lib import covercp 
     188            cherrypy.engine.on_start_engine_list.insert(0, covercp.start) 
     189            cherrypy.engine.on_start_thread_list.insert(0, covercp.start) 
    187190        except ImportError: 
    188191            coverage = None 
     
    192195        """Stop the coverage tool, save results, and report.""" 
    193196        import cherrypy 
    194         cherrypy.codecoverage = False 
     197        from cherrypy.lib import covercp 
     198        while covercp.start in cherrypy.engine.on_start_engine_list: 
     199            cherrypy.engine.on_start_engine_list.remove(covercp.start) 
     200        while covercp.start in cherrypy.engine.on_start_thread_list: 
     201            cherrypy.engine.on_start_thread_list.remove(covercp.start) 
    195202        if self.coverage: 
    196203            self.coverage.save() 

Hosted by WebFaction

Log in as guest/cpguest to create tickets