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

Changeset 603

Show
Ignore:
Timestamp:
09/04/05 15:27:10
Author:
mikerobi
Message:

httperrors: undid some of the assertion changes in the test, by takeing advantage of the the new ability to disable httperrors in production mode, in configuration "showTracebacks" is now "server.showTracebacks" and defaults to True

Files:

Legend:

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

    r555 r603  
    8282            body = StringIO.StringIO(body) 
    8383         
    84         cherrypy.server.request(self.HOST, self.HOST, requestLine
    85                                 headers, body, "http") 
     84        cherrypy.server.request((self.HOST, self.PORT), self.HOST
     85                                requestLine, headers, body, "http") 
    8686         
    8787        self.status = cherrypy.response.status 
  • branches/httperrors/cherrypy/test/test_core.py

    r602 r603  
    248248cherrypy.config.update({ 
    249249    'global': {'server.logToScreen': False, 
     250               'server.httpErrors' : False, 
    250251               'server.environment': 'production', 
    251252               'server.showTracebacks': True, 
     
    457458        self.getPage("/error/missing") 
    458459        self.assertStatus("404 Not Found") 
    459         self.assertInBody("404 Not Found") 
     460        self.assertInBody("NotFound") 
    460461         
    461462        ignore = helper.webtest.ignored_exceptions 
    462463        ignore.append(ValueError) 
    463464        try: 
     465            valerr = r'\n    raise ValueError\(\)\nValueError\n$' 
    464466            self.getPage("/error/page_method") 
    465             self.assertInBody('raise ValueError()'
     467            self.assertMatchesBody(valerr
    466468             
    467469            import cherrypy 
    468470            proto = cherrypy.config.get("server.protocolVersion", "HTTP/1.0") 
    469471            if proto == "HTTP/1.1": 
    470                 valerr = r'<h2>500 Internal error</h2>
     472                valerr = r'Unrecoverable error in the server.$
    471473            self.getPage("/error/page_yield") 
    472             self.assertInBody(valerr) 
     474            self.assertMatchesBody(valerr) 
    473475             
    474476            if cherrypy._httpserver is None and proto == "HTTP/1.0": 
     
    479481                # started, the status should not change to an error status. 
    480482                self.assertStatus("200 OK") 
    481                 self.assertInBody("hello<?xml version") 
     483                self.assertBody("helloUnrecoverable error in the server.") 
    482484             
    483485            self.getPage("/error/cause_err_in_finalize") 
  • branches/httperrors/cherrypy/test/test_gzip_filter.py

    r602 r603  
    4646        'server.logToScreen': False, 
    4747        'server.environment': 'production', 
     48        'server.httpErrors': False, 
    4849        'server.showTracebacks': True, 
    4950        'gzipFilter.on': True, 
     
    8283            else: 
    8384                self.assertNoHeader('Content-Encoding') 
    84                 self.assertStatus('500 Internal error') 
    85                 self.assertInBody("IndexError") 
     85                self.assertMatchesBody(r"IndexError\n$") 
    8686        finally: 
    8787            helper.webtest.ignored_exceptions.pop() 
  • branches/httperrors/cherrypy/test/test_session_filter.py

    r581 r603  
    2727""" 
    2828 
    29 import cherrypy 
     29import cherrypy, time, os 
    3030 
    3131class Root: 
    32     def index(self): 
     32    def testGen(self): 
    3333        counter = cherrypy.session.get('counter', 0) + 1 
    3434        cherrypy.session['counter'] = counter 
    3535        yield str(counter) 
    36     index.exposed = True 
     36    testGen.exposed = True 
     37    def testStr(self): 
     38        counter = cherrypy.session.get('counter', 0) + 1 
     39        cherrypy.session['counter'] = counter 
     40        return str(counter) 
     41    testStr.exposed = True 
    3742     
    3843cherrypy.root = Root() 
     
    4146        'server.environment': 'production', 
    4247        'sessionFilter.on': True, 
     48        'sessionFilter.storageType' : 'file', 
     49        'sessionFilter.storagePath' : '.', 
    4350}) 
    4451 
     
    4855     
    4956    def testSessionFilter(self): 
    50         self.getPage('/') 
     57        self.getPage('/testStr') 
    5158        self.assertBody('1') 
    52         self.getPage('/', self.cookies) 
     59        self.getPage('/testGen', self.cookies) 
    5360        self.assertBody('2') 
    54         self.getPage('/', self.cookies) 
     61        self.getPage('/testStr', self.cookies) 
    5562        self.assertBody('3') 
     63        cherrypy.config.update({ 
     64            'sessionFilter.storageType' : 'file', 
     65        }) 
     66        self.getPage('/testStr') 
     67        self.assertBody('1') 
     68        self.getPage('/testGen', self.cookies) 
     69        self.assertBody('2') 
     70        self.getPage('/testStr', self.cookies) 
     71        self.assertBody('3') 
     72 
     73        # Clean up session files 
     74        for fname in os.listdir('.'): 
     75            if fname.startswith('session-'): 
     76                os.unlink(fname) 
     77         
    5678         
    5779if __name__ == "__main__": 

Hosted by WebFaction

Log in as guest/cpguest to create tickets