Issue #801 wontfix

cherrypy._cpwsgi.CPWSGIApp is incompatible with twill 0.9b1

Anonymous created an issue

In trying to write nose/twill unit tests for a CherryPy 3 application, I was unable to use cherrypy._cpwsgi.CPWSGIApp as the twill app-creation function. My specific CherryPy application class worked fine as the app-creation function.

Here's a script to demonstrate the problem. {{{

!/usr/bin/env python

encoding: utf-8

import sys, logging, StringIO, twill, cherrypy from twill import commands from cherrypy._cpwsgi import CPWSGIApp

class DemoApp(object): @cherrypy.expose def index(self, args, *kw): return '''<html><head><title>Test</title></head> <body><p>This is a test.</p></body> </html>'''

class TestCase(object): def setup(self): siteSettings = {'server.environment': 'development', 'server.socket_port': 8080, 'log.screen': False} cherrypy.config.update(siteSettings) wsgi_app = cherrypy.tree.mount(DemoApp(), "/", {}) cherrypy.engine.start()

    def getApp():
        # return wsgi_app   # This works.
        return CPWSGIApp   # This does not.

    twill.add_wsgi_intercept('localhost', 8080, getApp)
    self.outp = StringIO.StringIO()
    twill.set_output(self.outp)

def teardown(self):
    twill.remove_wsgi_intercept('localhost', 8080)
    cherrypy.engine.stop()
    logging.debug("Twill output:\n%s" % self.outp.getvalue())

def test1(self):
    commands.go("http://localhost:8080/index")

def main(): logging.basicConfig(level=logging.DEBUG)

import nose
logging.debug("sys.platform: %s" % sys.platform)
logging.debug("Using CherryPy %s, twill %s, nose %s" % 
              (cherrypy.__version__, twill.__version__, nose.__version__))
nose.main(defaultTest=__file__)

if name == "main": main() }}}

When run with Python 2.5.2, CherryPy 3.1.0beta3, twill 0.9b1 and nose 0.10.1 on Mac OS X 10.5.2, this produces a traceback ending in {{{ File ".../lib/python2.5/site-packages/CherryPy-3.1b1-py2.5.egg/cherrypy/_cpwsgi.py", line 291, in init self.pipeline.extend(pipeline) TypeError: 'function' object is not iterable }}}

The problem was first observed with CherryPy 3.0.2.

Reported by mchapman87501@gmail.com

Comments (2)

  1. Log in to comment