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

Changeset 1340

Show
Ignore:
Timestamp:
09/08/06 13:09:59
Author:
fumanchu
Message:

Test support for wsgiref.validate (new '--validate' arg to test.py), plus a couple minor fixes based on the first validation run.

Files:

Legend:

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

    r1332 r1340  
    216216        # Must use keys() here for Python 2.3 (rfc822.Message had no __iter__). 
    217217        for k in headers.keys(): 
     218            if k in ('transfer-encoding', 'content-type', 'content-length'): 
     219                continue 
     220             
    218221            envname = "HTTP_" + k.upper().replace("-", "_") 
    219222            if k in comma_separated_headers: 
     
    223226                else: 
    224227                    environ[envname] = ", ".join(headers.getheaders(k)) 
    225             elif k in ('Transfer-Encoding',): 
    226                 pass 
    227228            else: 
    228229                environ[envname] = headers[k] 
  • trunk/cherrypy/lib/wsgiapp.py

    r1288 r1340  
    1 """a WSGI application tool for CherryPy""" 
     1"""A CherryPy tool for hosting a foreign WSGI application.""" 
    22 
    33import sys 
  • trunk/cherrypy/test/helper.py

    r1278 r1340  
    102102                                        args=(moduleNames, conf)) 
    103103 
    104 def sync_apps(profile=False): 
     104def sync_apps(profile=False, validate=False): 
    105105    apps = [] 
    106106    for base, app in cherrypy.tree.apps.iteritems(): 
     
    108108            base = "" 
    109109        if profile: 
    110             apps.append((base, profiler.make_app(app, aggregate=False))) 
    111         else: 
    112             apps.append((base, app)) 
     110            app = profiler.make_app(app, aggregate=False) 
     111        if validate: 
     112            try: 
     113                from wsgiref import validate 
     114            except ImportError: 
     115                warnings.warn("Error importing wsgiref. The validator will not run.") 
     116            app = validate.validator(app) 
     117        apps.append((base, app)) 
    113118    apps.sort() 
    114119    apps.reverse() 
     
    131136        # The setup functions probably mounted new apps. 
    132137        # Tell our server about them. 
    133         sync_apps(profile=conf.get("profiling.on", False)) 
     138        sync_apps(profile=conf.get("profiling.on", False), 
     139                  validate=conf.get("validator.on", False)) 
    134140         
    135141        suite = CPTestLoader.loadTestsFromName(testmod) 
  • trunk/cherrypy/test/test.py

    r1330 r1340  
    8585        self.cover = False 
    8686        self.profile = False 
     87        self.validate = False 
    8788        self.server = None 
    8889        self.protocol = "HTTP/1.1" 
    8990         
    90         longopts = ['cover', 'profile', '1.0', 'help', 'basedir=', 'port=', 
     91        longopts = ['cover', 'profile', 'validate', '1.0', 'help', 'basedir=', 'port=', 
    9192                    'server='] 
    9293        longopts.extend(self.available_tests) 
     
    108109            elif o == "--profile": 
    109110                self.profile = True 
     111            elif o == "--validate": 
     112                self.validate = True 
    110113            elif o == "--1.0": 
    111114                self.protocol = "HTTP/1.0" 
     
    140143        print """CherryPy Test Program 
    141144    Usage: 
    142         test.py --server=* --port=%s --1.0 --cover --basedir=path --profile --tests** 
     145        test.py --server=* --port=%s --1.0 --cover --basedir=path --profile --validate --tests** 
    143146         
    144147    """ % self.__class__.port 
     
    159162     
    160163    --profile: turn on profiling tool 
     164    --validate: use wsgiref.validate (builtin in Python 2.5). 
    161165    """ % self.__class__.port 
    162166         
     
    265269            conf['profiling.on'] = True 
    266270         
     271        if self.validate: 
     272            conf = conf or {} 
     273            conf['validator.on'] = True 
     274         
    267275        if self.server == 'cpmodpy': 
    268276            from cherrypy.test import modpy 
     
    281289         
    282290        if self.profile: 
    283             del conf['profiling.on'] 
    284291            print 
    285292            print ("run /cherrypy/lib/profiler.py as a script to serve " 
  • trunk/cherrypy/test/test_config.py

    r1336 r1340  
    5757            handler = cherrypy.request.handler 
    5858            def wrapper(): 
     59                # 'value' is a type (like int or str). 
    5960                return value(handler()) 
    6061            cherrypy.request.handler = wrapper 
  • trunk/cherrypy/test/test_wsgiapps.py

    r1275 r1340  
    2727            results = list(results) 
    2828            results.reverse() 
    29             return "".join(results) 
     29            return ["".join(results)] 
    3030        return _app 
    3131     

Hosted by WebFaction

Log in as guest/cpguest to create tickets