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

Changeset 495

Show
Ignore:
Timestamp:
07/22/05 13:39:23
Author:
fumanchu
Message:

1. Moved top-level test functions into a new TestHarness? class.
2. Removed helper.HOST and .PORT.
3. Removed helper.port_is_free, since cherrypy.server now checks for free port.

Files:

Legend:

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

    r489 r495  
    4242        webtest.ignored_exceptions.append(y) 
    4343 
    44 HOST = "127.0.0.1" 
    45 PORT = 8000 
    46  
    47  
    48 def port_is_free(): 
    49     """Return True if helper.PORT is free on helper.HOST, otherwise False.""" 
    50     try: 
    51         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
    52         s.connect((HOST, PORT)) 
    53         s.close() 
    54         return False 
    55     except socket.error: 
    56         return True 
    57  
    5844 
    5945def startServer(serverClass=None): 
     
    6248        cherrypy.server.start(initOnly=True) 
    6349    else: 
    64         if not port_is_free(): 
    65             raise IOError("Port %s is in use; perhaps the previous server " 
    66                           "did not shut down properly." % PORT) 
    67         t = threading.Thread(target=cherrypy.server.start, args=(False, serverClass)) 
     50        t = threading.Thread(target=cherrypy.server.start, 
     51                             args=(False, serverClass)) 
    6852        t.start() 
    6953        time.sleep(1) 
     
    9377         
    9478        requestLine = "%s %s HTTP/1.1" % (method.upper(), url) 
    95         headers = webtest.cleanHeaders(headers, method, body, HOST, PORT) 
     79        headers = webtest.cleanHeaders(headers, method, body, 
     80                                       self.HOST, self.PORT) 
    9681        if body is not None: 
    9782            body = StringIO.StringIO(body) 
    9883         
    99         cherrypy.server.request(HOST, HOST, requestLine, headers, body, "http") 
     84        cherrypy.server.request(self.HOST, self.HOST, requestLine, 
     85                                headers, body, "http") 
    10086         
    10187        self.status = cherrypy.response.status 
     
    135121CPTestLoader = webtest.ReloadingTestLoader() 
    136122CPTestRunner = webtest.TerseTestRunner(verbosity=2) 
    137  
    138  
    139 def report_coverage(coverage, basedir=None): 
    140     """Print a summary from the code coverage tool.""" 
    141      
    142     if not basedir: 
    143         # Assume we want to cover everything starting with "cherrypy/" 
    144         localDir = os.path.dirname(__file__) 
    145         basedir = os.path.normpath(os.path.join(os.getcwd(), localDir, '../')) 
    146      
    147     coverage.get_ready() 
    148     morfs = [x for x in coverage.cexecuted if x.startswith(basedir.lower())] 
    149      
    150     total_statements = 0 
    151     total_executed = 0 
    152      
    153     print 
    154     print "CODE COVERAGE (this might take a while)", 
    155     for morf in morfs: 
    156         sys.stdout.write(".") 
    157         sys.stdout.flush() 
    158         name = os.path.split(morf)[1] 
    159         try: 
    160             _, statements, _, missing, readable  = coverage.analysis2(morf) 
    161             n = len(statements) 
    162             m = n - len(missing) 
    163             total_statements = total_statements + n 
    164             total_executed = total_executed + m 
    165         except KeyboardInterrupt: 
    166             raise 
    167         except: 
    168             # No, really! We truly want to ignore any other errors. 
    169             pass 
    170      
    171     pc = 100.0 
    172     if total_statements > 0: 
    173         pc = 100.0 * total_executed / total_statements 
    174      
    175     print ("\nTotal: %s Covered: %s Percent: %2d%%" 
    176            % (total_statements, total_executed, pc)) 
    177123 
    178124 
  • trunk/cherrypy/test/test.py

    r489 r495  
    3030import os, os.path 
    3131import webtest 
    32  
    33 try: 
    34     set 
    35 except NameError: 
    36     from sets import Set as set 
    37  
    38  
    39 def help(testList): 
    40     """Print help for test.py command-line options.""" 
    41      
    42     print """CherryPy Test Program 
    43     Usage:  
    44         test.py -mode -cover -profile -1.1 testName1 testName2 testName... 
    45      
    46     modes: wsgi, severless, native, all (default is wsgi) 
    47      
    48     cover: turns on code-coverage tool 
    49      
    50     profile: turns on profiling tool 
     32import getopt 
     33 
     34 
     35class TestHarness(object): 
     36     
     37    """A test harness for the CherryPy framework and CherryPy applications.""" 
     38     
     39    # The first server in the list is the default server. 
     40    available_servers = {'serverless': (0, "Serverless", None), 
     41                         'native': (1, "Native HTTP Server", 
     42                                    "cherrypy._cphttpserver.embedded_server"), 
     43                         'wsgi': (2, "Native WSGI Server", 
     44                                  "cherrypy._cpwsgi.WSGIServer"), 
     45                         } 
     46    default_server = "wsgi" 
     47     
     48    def __init__(self, available_tests): 
     49        """Constructor to populate the TestHarness instance. 
     50         
     51        available_tests should be a list of module names (strings). 
     52        """ 
     53        self.available_tests = available_tests 
     54         
     55        self.cover = False 
     56        self.profile = False 
     57        self.protocol = "HTTP/1.0" 
     58        self.basedir = None 
     59         
     60        self.servers = [] 
     61        self.tests = [] 
     62     
     63    def load(self, args=sys.argv[1:]): 
     64        """Populate a TestHarness from sys.argv. 
     65         
     66        args defaults to sys.argv[1:], but you can provide a different 
     67            set of args if you like. 
     68        """ 
     69         
     70        longopts = ['cover', 'profile', '1.1', 'help', 'basedir=', 'all'] 
     71        longopts.extend(self.available_servers) 
     72        longopts.extend(self.available_tests) 
     73        try: 
     74            opts, args = getopt.getopt(args, "", longopts) 
     75        except getopt.GetoptError: 
     76            # print help information and exit 
     77            self.help() 
     78            sys.exit(2) 
     79         
     80        self.cover = False 
     81        self.profile = False 
     82        self.protocol = "HTTP/1.0" 
     83        self.basedir = None 
     84         
     85        self.servers = [] 
     86        self.tests = [] 
     87         
     88        for o, a in opts: 
     89            if o == '--help': 
     90                self.help() 
     91                sys.exit() 
     92            elif o == "--cover": 
     93                self.cover = True 
     94            elif o == "--profile": 
     95                self.profile = True 
     96            elif o == "-1.1": 
     97                self.protocol = "HTTP/1.1" 
     98            elif o == "--basedir": 
     99                self.basedir = a 
     100            elif o == "--all": 
     101                self.servers = self.available_servers.keys() 
     102            else: 
     103                o = o[2:] 
     104                if o in self.available_servers and o not in self.servers: 
     105                    self.servers.append(o) 
     106                elif o in self.available_tests and o not in self.tests: 
     107                    self.tests.append(o) 
     108         
     109        if self.cover and self.profile: 
     110            # Print error message and exit 
     111            print ('Error: you cannot run the profiler and the ' 
     112                   'coverage tool at the same time.') 
     113            sys.exit(2) 
     114         
     115        if not self.servers: 
     116            self.servers = [self.default_server] 
     117         
     118        if not self.tests: 
     119            self.tests = self.available_tests[:] 
     120     
     121    def help(self): 
     122        """Print help for test.py command-line options.""" 
     123         
     124        print """CherryPy Test Program 
     125    Usage: 
     126        test.py --server --1.1 --cover --basedir=path --profile --test 
     127    """ 
     128        print '    servers:' 
     129        s = [(val, name) for name, val in self.available_servers.iteritems()] 
     130        s.sort() 
     131        for val, name in s: 
     132            if name == self.default_server: 
     133                print '        ', name, '(default)' 
     134            else: 
     135                print '        ', name 
     136         
     137        print """         all (runs all servers in order) 
    51138     
    52139    1.1: use HTTP/1.1 servers instead of default HTTP/1.0 
     140     
     141    cover: turn on code-coverage tool 
     142    basedir=path: display coverage stats for some path other than cherrypy. 
     143     
     144    profile: turn on profiling tool 
    53145    """ 
    54      
    55     print '    tests:' 
    56     for name in testList: 
    57         print '        ', name 
    58  
    59  
    60 class BadArgument(Exception): 
    61     pass 
    62  
    63 class DisplayHelp(Exception): 
    64     pass 
    65  
    66  
    67 class Options: 
    68      
    69     """A container for test.py command-line options.""" 
    70      
    71     def __init__(self, args, testList): 
    72         """Constructor to populate the Options instance. 
    73          
    74         args is usually sys.argv[1:]. 
    75         testList should be a list of module names (strings). 
     146         
     147        print '    tests:' 
     148        for name in self.available_tests: 
     149            print '        ', name 
     150     
     151    def start_coverage(self): 
     152        """Start the coverage tool. 
     153         
     154        To use this feature, you need to download 'coverage.py', 
     155        either Gareth Rees' original implementation: 
     156        http://www.garethrees.org/2001/12/04/python-coverage/ 
     157         
     158        or Ned Batchelder's enhanced version: 
     159        http://www.nedbatchelder.com/code/modules/coverage.html 
     160         
     161        If neither module is found in PYTHONPATH, coverage is disabled. 
    76162        """ 
    77          
    78         argSet = set([arg.lower() for arg in args]) 
    79          
    80         if '-help' in args: 
    81             raise DisplayHelp 
    82          
    83         servers = set() 
    84         if '-all' in argSet: 
    85             servers.update(['wsgi', 'native', 'serverless']) 
     163        try: 
     164            from coverage import the_coverage as coverage 
     165            c = os.path.join(os.path.dirname(__file__), "../lib/coverage.cache") 
     166            coverage.cache_default = c 
     167            if c and os.path.exists(c): 
     168                os.remove(c) 
     169            coverage.start() 
     170            import cherrypy 
     171            cherrypy.codecoverage = True 
     172        except ImportError: 
     173            coverage = None 
     174        self.coverage = coverage 
     175     
     176    def stop_coverage(self): 
     177        """Stop the coverage tool, save results, and report.""" 
     178        import cherrypy 
     179        cherrypy.codecoverage = False 
     180        if self.coverage: 
     181            self.coverage.save() 
     182            self.report_coverage() 
     183            print ("run cherrypy/lib/covercp.py as a script to serve " 
     184                   "coverage results on port 8080") 
     185     
     186    def report_coverage(self): 
     187        """Print a summary from the code coverage tool.""" 
     188         
     189        basedir = self.basedir 
     190        if basedir is None: 
     191            # Assume we want to cover everything in "../../cherrypy/" 
     192            localDir = os.path.dirname(__file__) 
     193            basedir = os.path.normpath(os.path.join(os.getcwd(), localDir, '../')) 
    86194        else: 
    87             if '-native' in argSet: 
    88                 servers.add('native') 
    89             if '-serverless' in argSet: 
    90                 servers.add('serverless') 
    91             if '-wsgi' in argSet or not servers: 
    92                 servers.add('wsgi') 
    93         self.servers = servers 
    94         argSet.difference_update(['-wsgi', '-native', '-serverless', '-all']) 
    95          
    96         self.cover = ("-cover" in argSet) 
    97         self.profile = ("-profile" in argSet) 
    98         if self.cover and self.profile: 
    99             raise BadArgument('Bad Arguments: you cannot run the profiler and the coverage tool at the same time.') 
    100         argSet.difference_update(['-cover', '-profile']) 
    101          
    102         if "-1.1" in argSet: 
    103             self.protocol = "HTTP/1.1" 
    104             argSet.difference_update(['-1.1']) 
    105         else: 
    106             self.protocol = "HTTP/1.0" 
    107          
    108         # All remaining args should be test names. 
    109         tests = [] 
    110         for name in testList: 
    111             if ("-" + name) in argSet: 
    112                 tests.append(name) 
    113                 argSet.discard("-" + name) 
    114         if not tests: 
    115             tests = testList 
    116         self.tests = tests 
    117          
    118         if len(argSet): 
    119             for arg in args: 
    120                 if arg.lower() in argSet: 
    121                     raise BadArgument('Bad Argument: %s is not a valid option.' % arg) 
    122  
    123 def get_coverage(): 
    124     """Return a coverage.the_coverage instance. 
    125      
    126     To use this feature, or the coverage server in cherrypy/lib/covercp, 
    127     you need to download 'coverage.py', either Gareth Rees' original 
    128     implementation: 
    129     http://www.garethrees.org/2001/12/04/python-coverage/ 
    130      
    131     or Ned Batchelder's enhanced version: 
    132     http://www.nedbatchelder.com/code/modules/coverage.html 
    133      
    134     If neither module is found in PYTHONPATH, this module returns None. 
    135     """ 
    136     try: 
    137         from coverage import the_coverage as coverage 
    138         c = os.path.join(os.path.dirname(__file__), "../lib/coverage.cache") 
    139         coverage.cache_default = c 
    140         if c and os.path.exists(c): 
    141             os.remove(c) 
    142         coverage.start() 
    143     except ImportError: 
    144         coverage = None 
    145     return coverage 
    146  
    147  
    148 def main(opts, conf=None, includeNotReady=False): 
    149     """Run the test suite against multiple servers and other options. 
    150      
    151     opts should be an Options instance, with the following attributes: 
    152         tests = a list of module names 
    153         servers = a list of servers (serverless, wsgi, native, all) 
    154         cover = whether or not to run the coverage tool 
    155         profile = whether or not to run the profiling tool 
    156         protocol = the HTTP protocol version for requests, e.g. "HTTP/1.0" 
    157      
    158     conf may be a dictionary or a filename (string). 
    159      
    160     includeNotReady specifies whether or not to run the NotReadyTest, 
    161         (which is typically only run for cherrypy itself; other apps 
    162         which use this module may safely leave it off/False). 
    163      
    164     """ 
    165      
    166     if opts.cover: 
     195            if not os.path.isabs(basedir): 
     196                basedir = os.path.normpath(os.path.join(os.getcwd(), basedir)) 
     197        basedir = basedir.lower() 
     198         
     199        self.coverage.get_ready() 
     200        morfs = [x for x in self.coverage.cexecuted 
     201                 if x.lower().startswith(basedir)] 
     202         
     203        total_statements = 0 
     204        total_executed = 0 
     205         
     206        print 
     207        print "CODE COVERAGE (this might take a while)", 
     208        for morf in morfs: 
     209            sys.stdout.write(".") 
     210            sys.stdout.flush() 
     211            name = os.path.split(morf)[1] 
     212            try: 
     213                _, statements, _, missing, readable  = self.coverage.analysis2(morf) 
     214                n = len(statements) 
     215                m = n - len(missing) 
     216                total_statements = total_statements + n 
     217                total_executed = total_executed + m 
     218            except KeyboardInterrupt: 
     219                raise 
     220            except: 
     221                # No, really! We truly want to ignore any other errors. 
     222                pass 
     223         
     224        pc = 100.0 
     225        if total_statements > 0: 
     226            pc = 100.0 * total_executed / total_statements 
     227         
     228        print ("\nTotal: %s Covered: %s Percent: %2d%%" 
     229               % (total_statements, total_executed, pc)) 
     230     
     231    def run(self, conf=None): 
     232        """Run the test harness.""" 
     233        self.load() 
     234         
    167235        # Start the coverage tool before importing cherrypy, 
    168236        # so module-level global statements are covered. 
    169         coverage = get_coverage() 
    170      
    171     import cherrypy 
    172     print "Python version used to run this test script:", sys.version.split()[0] 
    173     print "CherryPy version", cherrypy.__version__ 
    174     print 
    175      
    176     from cherrypy.test import helper 
    177      
    178     if includeNotReady: 
     237        if self.cover: 
     238            self.start_coverage() 
     239         
     240        import cherrypy 
     241        print "Python version used to run this test script:", sys.version.split()[0] 
     242        print "CherryPy version", cherrypy.__version__ 
     243        print 
     244         
     245        if conf is None: 
     246            conf = {'global': {'server.socketHost': '127.0.0.1', 
     247                               'server.socketPort': 8000, 
     248                               'server.threadPool': 10, 
     249                               'server.logToScreen': False, 
     250                               'server.environment': "production", 
     251                               } 
     252                    } 
     253        elif isinstance(conf, basestring): 
     254            conf = cherrypy.config.dict_from_config_file(conf) 
     255         
     256        conf['server.protocolVersion'] = self.protocol 
     257         
     258        if self.profile: 
     259            conf['profiling.on'] = True 
     260         
     261        self._run_all_servers(conf) 
     262         
     263        if self.profile: 
     264            del conf['profiling.on'] 
     265            print 
     266            print ("run /cherrypy/lib/profiler.py as a script to serve " 
     267                   "profiling results on port 8080") 
     268         
     269        if self.cover: 
     270            self.stop_coverage() 
     271     
     272    def _run_all_servers(self, conf): 
     273        # helper must be imported lazily so the coverage tool 
     274        # can run against module-level statements within cherrypy. 
     275        from cherrypy.test import helper 
     276        s = [self.available_servers[name] for name in self.servers] 
     277        s.sort() 
     278        for priority, name, cls in s: 
     279            print 
     280            print "Running tests:", name 
     281            helper.run_test_suite(self.tests, cls, conf) 
     282 
     283 
     284class CPTestHarness(TestHarness): 
     285     
     286    def _run_all_servers(self, conf): 
     287        from cherrypy.test import helper 
     288         
    179289        class NotReadyTest(helper.CPWebCase): 
    180290            def testNotReadyError(self): 
     
    182292                # get a NotReady error 
    183293                class Root: pass 
     294                import cherrypy 
    184295                cherrypy.root = Root() 
    185296                self.assertRaises(cherrypy.NotReady, self.getPage, "/") 
    186297        helper.CPTestRunner.run(NotReadyTest("testNotReadyError")) 
    187      
    188     if conf is None: 
    189         conf = {'global': {'server.socketHost': helper.HOST, 
    190                            'server.socketPort': helper.PORT, 
    191                            'server.threadPool': 10, 
    192                            'server.logToScreen': False, 
    193                            'server.environment': "production", 
    194                            } 
    195                 } 
    196     elif isinstance(conf, basestring): 
    197         conf = cherrypy.config.dict_from_config_file(conf) 
    198      
    199     conf['server.protocolVersion'] = opts.protocol 
    200      
    201     if opts.cover: 
    202         cherrypy.codecoverage = True 
    203      
    204     if opts.profile: 
    205         conf['profiling.on'] = True 
    206      
    207     if 'serverless' in opts.servers: 
    208         print 
    209         print "Running tests: Serverless" 
    210         helper.run_test_suite(opts.tests, None, conf) 
    211      
    212     if 'native' in opts.servers: 
    213         print 
    214         print "Running tests: Native HTTP Server" 
    215         helper.run_test_suite(opts.tests, 
    216                               "cherrypy._cphttpserver.embedded_server", 
    217                               conf) 
    218      
    219     if 'wsgi' in opts.servers: 
    220         print 
    221         print "Running tests: Native WSGI Server" 
    222         helper.run_test_suite(opts.tests, 
    223                               "cherrypy._cpwsgi.WSGIServer", 
    224                               conf) 
    225      
    226     if opts.profile or opts.cover: 
    227         print 
    228      
    229     if opts.profile: 
    230         del conf['profiling.on'] 
    231         print "run /cherrypy/lib/profiler.py as a script to serve profiling results on port 8080" 
    232      
    233     if opts.cover: 
    234         cherrypy.codecoverage = False 
    235         if coverage: 
    236             coverage.save() 
    237             helper.report_coverage(coverage) 
    238             print "run /cherrypy/lib/covercp.py as a script to serve coverage results on port 8080" 
     298         
     299        TestHarness._run_all_servers(self, conf) 
    239300 
    240301 
    241302if __name__ == '__main__': 
     303     
     304    # Place this __file__'s grandparent (../../) at the start of sys.path, 
     305    # so that all cherrypy/* imports are from this __file__'s package. 
     306    localDir = os.path.dirname(__file__) 
     307    curpath = os.path.normpath(os.path.join(os.getcwd(), localDir)) 
     308    sys.path.insert(0, os.path.normpath(os.path.join(curpath, '../../'))) 
    242309     
    243310    testList = [ 
     
    255322##        'test_session_filter', 
    256323    ] 
    257      
    258     try: 
    259         opts = Options(sys.argv[1:], testList) 
    260     except DisplayHelp: 
    261         help(testList) 
    262     except BadArgument, argError: 
    263         print argError 
    264     else: 
    265         # Place our current directory's parent (cherrypy/) at the beginning 
    266         # of sys.path, so that all imports are from our current directory. 
    267         localDir = os.path.dirname(__file__) 
    268         curpath = os.path.normpath(os.path.join(os.getcwd(), localDir)) 
    269         sys.path.insert(0, os.path.normpath(os.path.join(curpath, '../../'))) 
    270          
    271         main(opts, includeNotReady=True) 
     324    CPTestHarness(testList).run() 
    272325     
    273326    print 
  • trunk/cherrypy/test/test_objectmapping.py

    r474 r495  
    130130        self.assert_(self.status in ('302 Found', '303 See Other')) 
    131131        self.assertHeader('Location', 'http://%s:%s/dir1/dir2/' 
    132                           % (helper.HOST, helper.PORT)) 
     132                          % (self.HOST, self.PORT)) 
    133133         
    134134        self.getPage("/dir1/dir2/dir3/dir4/index") 
     
    138138        self.assertStatus('302 Found') 
    139139        self.assertHeader('Location', 'http://%s:%s/dir1/' 
    140                           % (helper.HOST, helper.PORT)) 
     140                          % (self.HOST, self.PORT)) 
    141141 
    142142 
  • trunk/cherrypy/test/test_session_filter.py

    r474 r495  
    4343               'global': 
    4444                   { 
    45                     'server.socketHost': helper.HOST
    46                     'server.socketPort': helper.PORT
     45                    'server.socketHost': '127.0.0.1'
     46                    'server.socketPort': 8000
    4747                    'server.threadPool': 5, 
    4848                    'server.logToScreen': False, 
  • trunk/cherrypy/test/test_tutorials.py

    r474 r495  
    3333from cherrypy.test import helper 
    3434 
    35 server_conf = {'server.socketHost': helper.HOST, 
    36                'server.socketPort': helper.PORT, 
    37                'server.threadPool': 10, 
    38                'server.logToScreen': False, 
    39                'server.environment': "production", 
    40 ##               'profiling.on': True, 
    41                } 
    42  
    43 def load_tut_module(tutorialName): 
    44     """Import or reload tutorial module as needed.""" 
    45     cherrypy.config.reset() 
    46     cherrypy.config.update({'global': server_conf.copy()}) 
    47      
    48     target = "cherrypy.tutorial." + tutorialName 
    49     if target in sys.modules: 
    50         module = reload(sys.modules[target]) 
    51     else: 
    52         module = __import__(target, globals(), locals(), ['']) 
    53      
    54     cherrypy.server.start(initOnly=True) 
    55  
    5635 
    5736class TutorialTest(helper.CPWebCase): 
    5837     
     38    def load_tut_module(self, tutorialName): 
     39        """Import or reload tutorial module as needed.""" 
     40        cherrypy.config.reset() 
     41        cherrypy.config.update({'global': {'server.socketHost': self.HOST, 
     42                                           'server.socketPort': self.PORT, 
     43                                           'server.threadPool': 10, 
     44                                           'server.logToScreen': False, 
     45                                           'server.environment': "production", 
     46                                           }}) 
     47         
     48        target = "cherrypy.tutorial." + tutorialName 
     49        if target in sys.modules: 
     50            module = reload(sys.modules[target]) 
     51        else: 
     52            module = __import__(target, globals(), locals(), ['']) 
     53         
     54        cherrypy.server.start(initOnly=True) 
     55     
    5956    def test01HelloWorld(self): 
    60         load_tut_module("tut01_helloworld") 
     57        self.load_tut_module("tut01_helloworld") 
    6158        self.getPage("/") 
    6259        self.assertBody('Hello world!') 
    6360     
    6461    def test02ExposeMethods(self): 
    65         load_tut_module("tut02_expose_methods") 
     62        self.load_tut_module("tut02_expose_methods") 
    6663        self.getPage("/showMessage") 
    6764        self.assertBody('Hello world!') 
    6865     
    6966    def test03GetAndPost(self): 
    70         load_tut_module("tut03_get_and_post") 
     67        self.load_tut_module("tut03_get_and_post") 
    7168         
    7269        # Try different GET queries 
     
    8885     
    8986    def test04ComplexSite(self): 
    90         load_tut_module("tut04_complex_site") 
     87        self.load_tut_module("tut04_complex_site") 
    9188        msg = ''' 
    9289            <p>Here are some extra useful links:</p> 
     
    10299     
    103100    def test05DerivedObjects(self): 
    104         load_tut_module("tut05_derived_objects") 
     101        self.load_tut_module("tut05_derived_objects") 
    105102        msg = ''' 
    106103            <html> 
     
    122119     
    123120    def test06DefaultMethod(self): 
    124         load_tut_module("tut06_default_method") 
     121        self.load_tut_module("tut06_default_method") 
    125122        self.getPage('/hendrik') 
    126123        self.assertBody('Hendrik Mans, CherryPy co-developer & crazy German ' 
    127124                         '(<a href="./">back</a>)') 
    128125    def test07Sessions(self): 
    129         load_tut_module("tut07_sessions") 
     126        self.load_tut_module("tut07_sessions") 
    130127        cherrypy.config.update({"global": {"sessionFilter.on": True}}) 
    131128         
     
    141138     
    142139    def test08AdvancedSessions(self): 
    143         load_tut_module("tut08_advanced_sessions") 
     140        self.load_tut_module("tut08_advanced_sessions") 
    144141        cherrypy.config.update({"global": {"sessionFilter.on": True}}) 
    145142         
     
    151148     
    152149    def test09GeneratorsAndYield(self): 
    153         load_tut_module("tut09_generators_and_yield") 
     150        self.load_tut_module("tut09_generators_and_yield") 
    154151        self.getPage('/') 
    155152        self.assertBody('<html><body><h2>Generators rule!</h2>' 
     
    159156     
    160157    def test10FileUpload(self): 
    161         load_tut_module("tut10_file_upload") 
     158        self.load_tut_module("tut10_file_upload") 
    162159         
    163160        h = [("Content-type", "multipart/form-data; boundary=x"), 
  • trunk/cherrypy/test/webtest.py

    r489 r495  
    285285 
    286286def cleanHeaders(headers, method, body, host, port): 
    287     """Return headers, with required headers added (if missing).""" 
     287    """Return request headers, with required headers added (if missing).""" 
    288288    if headers is None: 
    289289        headers = [] 
    290290     
    291     # Add the required Host header if not present 
     291    # Add the required Host request header if not present. 
     292    # [This specifies the host:port of the server, not the client.] 
    292293    found = False 
    293294    for k, v in headers: 

Hosted by WebFaction

Log in as guest/cpguest to create tickets